Create new {@link Link} with additional {@link Affordance}s.

@param affordances must not be {@literal null}.
@return
420084
public Link andAffordances(List<Affordance> affordances) {

		List<Affordance> newAffordances = new ArrayList<>();
		newAffordances.addAll(this.affordances);
		newAffordances.addAll(affordances);

		return withAffordances(newAffordances);
	}
274038
private static List<UberData> extractLinks(RepresentationModel<?> resource) {

		List<UberData> data = new ArrayList<>();

		List<UberData> links = extractLinks(resource.getLinks());
		List<UberData> affordanceBasedLinks = extractAffordances(resource.getLinks());

		if (affordanceBasedLinks.isEmpty()) {
			data.addAll(links);
		} else {
			data.addAll(mergeDeclaredLinksIntoAffordanceLinks(affordanceBasedLinks, links));
		}

		return data;
	}
547788
protected VelocityContext createContext()
    {
        VelocityContext context = new VelocityContext();
        context.put(META_KEY, META);
        context.put(UTILS_KEY, UTILS);
        context.put(MESSAGES_KEY, MESSAGES);
        return context;
    }
403921
public static <T> T newInstance(Class<T> clazz) {
		try {
			return clazz.newInstance();
		}
		catch (InstantiationException | IllegalAccessException e) {
			throw new ResourceException(String.format("couldn't create a new instance of %s", clazz));
		}
	}
882491
public T newInstance() {
        try {
            return getEnhancedClass().newInstance();
        } catch (Exception e) {
            logger.error("Could not instantiate enhanced object.", e);

            throw ExceptionUtil.propagate(e);
        }
    }
1254909
public Link withAffordances(List<Affordance> affordances) {

		return new Link(this.rel, this.href, this.hreflang, this.media, this.title, this.type, this.deprecation,
				this.profile, this.name, this.template, affordances);
	}
31245
public void addPossiblesFailuresComplex() {
        Set<Scenario> scenarios = this.getScenarios();
        for (Scenario s : scenarios) {
            for (Class<? extends Failure> c : s.getPossibleFailures().keySet()) {
                if (!this.getPossibleFailures().containsKey(c)) {
                    this.addPossibleFailure(c, s.getPossibleFailures().get(c));
                } else {
                    List<Set<NetworkElement>> elements = this
                            .getPossibleFailures().get(c);
                    // elements.addAll(s.getPossibleFailures().get(c));
                    for (Set<NetworkElement> sne : s.getPossibleFailures().get(
                            c)) {
                        if (!elements.contains(sne))
                            elements.add(sne);
                    }
                    this.addPossibleFailure(c, elements);
                }
            }
        }
    }
1081189
@Override
    public ClientlibLink makeLink() {
        return new ClientlibLink(getType(), ClientlibLink.Kind.CLIENTLIB, resource.getPath(), null);
    }
564285
@Nonnull
  public static NonBlockingProperties create (@Nullable final Map <?, ?> aProperties)
  {
    final NonBlockingProperties ret = new NonBlockingProperties ();
    if (aProperties != null)
      for (final Map.Entry <?, ?> aEntry : aProperties.entrySet ())
        ret.put ((String) aEntry.getKey (), (String) aEntry.getValue ());
    return ret;
  }
708534
@SuppressWarnings("unchecked")
	public T add(Link... links) {

		Assert.notNull(links, "Given links must not be null!");

		add(Arrays.asList(links));

		return (T) this;
	}
150332
public static SuperActivityToast create(@NonNull Context context, @NonNull Style style) {
        return (SuperActivityToast) new SuperActivityToast(context, style);
    }
1118503
public static <T> LinkedListJsonDeserializer<T> newInstance( JsonDeserializer<T> deserializer ) {
        return new LinkedListJsonDeserializer<T>( deserializer );
    }
849136
public static Arguments instance(Context context) {
        Arguments instance = context.get(argsKey);
        if (instance == null) {
            instance = new Arguments(context);
        }
        return instance;
    }
1231357
private static List<UberData> mergeDeclaredLinksIntoAffordanceLinks(List<UberData> affordanceBasedLinks,
			List<UberData> links) {

		return affordanceBasedLinks.stream() //
				.flatMap(affordance -> links.stream() //
						.filter(link -> link.getUrl().equals(affordance.getUrl())) //
						.map(link -> {

							if (link.getAction() == affordance.getAction()) {

								List<LinkRelation> rels = new ArrayList<>(link.getRel());
								rels.addAll(affordance.getRel());

								return affordance.withName(rels.get(0).value()) //
										.withRel(rels);
							} else {
								return affordance;
							}
						}))
				.collect(Collectors.toList());
	}
617241
public <T extends InteractionAwareFixture> T create(Class<T> clazz) {
        return create(clazz, null, null);
    }
602393
@Override
	public CPDefinitionLink create(long CPDefinitionLinkId) {
		CPDefinitionLink cpDefinitionLink = new CPDefinitionLinkImpl();

		cpDefinitionLink.setNew(true);
		cpDefinitionLink.setPrimaryKey(CPDefinitionLinkId);

		String uuid = PortalUUIDUtil.generate();

		cpDefinitionLink.setUuid(uuid);

		cpDefinitionLink.setCompanyId(companyProvider.getCompanyId());

		return cpDefinitionLink;
	}
830957
public static String makeDeepLink(String link){

        if(link != null
                // If getCurrentRemoteConnectionLink() == null means there is no current remote connection
                && getCurrentRemoteConnectionLink() != null
                // If containsRemoteParameter(link) is true means link already contain remote connection parameter
                && !containsRemoteParameter(link)) {

            link += (link.contains("?") ? "&" : "?") + PARAM_REMOTE_CONNECTION + "=" + getCurrentRemoteConnectionLink();

        }

        return link;

    }