List of usage examples for java.util Collection addAll
boolean addAll(Collection<? extends E> c);
From source file:net.sourceforge.fenixedu.applicationTier.Servico.manager.TransferDomainObjectProperty.java
@Atomic public static void run(DomainObject srcObject, DomainObject dstObject, String slotName) throws FenixServiceException { check(RolePredicates.MANAGER_PREDICATE); try {//from w ww . j a v a 2s.com Object srcProperty = PropertyUtils.getSimpleProperty(srcObject, slotName); if (srcProperty != null && srcProperty instanceof Collection) { Collection srcCollection = (Collection) srcProperty; Object dstProperty = PropertyUtils.getSimpleProperty(dstObject, slotName); if (dstProperty instanceof Collection) { Collection dstCollection = (Collection) dstProperty; dstCollection.addAll(srcCollection); } } else { PropertyUtils.setSimpleProperty(dstObject, slotName, srcProperty); } } catch (InvocationTargetException e) { if (e.getTargetException() != null) { if (e.getTargetException() instanceof WriteOnReadError) { throw ((WriteOnReadError) e.getTargetException()); } throw new FenixServiceException(e.getTargetException()); } throw new FenixServiceException(e); } catch (IllegalAccessException e) { throw new FenixServiceException(e); } catch (NoSuchMethodException e) { throw new FenixServiceException(e); } }
From source file:Main.java
/** * <p>Contact Collection A to Collection B</p> * @param <E>//from ww w . j a v a2 s. c o m * @param c1 * @param c2 * @return */ public static <E extends Object> Collection<E> contact(Collection<E> c1, Collection<E> c2) { if (c1 == null) { return c2; } else if (c2 == null) { return c1; } c1.addAll(c2); return c1; }
From source file:com.mothsoft.alexis.domain.UserAuthenticationDetails.java
private static Collection<GrantedAuthority> getAuthorities(final UserAuthenticationDetails user) { final Collection<GrantedAuthority> userAuthorities = new HashSet<GrantedAuthority>(); userAuthorities.addAll(user.getAuthorities()); return userAuthorities; }
From source file:Main.java
public static <T> Collection<T> flatten(Collection<T> original) { // First see if there are no nested collections // and in this case just return this boolean hasNested = false; for (Object o : original) { if (o instanceof Collection) { hasNested = true;//from w w w. j a v a2s . c om break; } } if (!hasNested) return original; // If there are nested collections Collection<T> flattened = createDefaultList(); for (T next : original) { if (next instanceof Collection) { flattened.addAll(flatten((Collection<T>) next)); } else { flattened.add(next); } } return flattened; }
From source file:org.springmodules.validation.valang.javascript.taglib.ValangJavaScriptTagUtils.java
/** * Inserts the provided validator into the model using the provided command name as the validation rule's key. If * there some rules that are already associated with the given command, the new rules will be added to them. * /*from w ww. ja va 2s . c o m*/ * @param commandName * the command name * @param validator * the valang validator * @param model * the model into which the validation rules will be placed */ public static void addValangRulesToModel(String commandName, Collection ruleSet, Map model) { Assert.notNull(commandName, "commandName is required."); String key = ValangValidateTag.VALANG_RULES_KEY_PREFIX + commandName; Collection rules = (Collection) model.get(key); if (rules == null) { rules = new ArrayList(); } rules.addAll(ruleSet); model.put(key, rules); }
From source file:Main.java
public static <E> void merge(final Collection<E> into, final Collection<E> values) { checkNotNull(into, "target cannot be null"); checkNotNull(values, "source cannot be null"); into.addAll(values); }
From source file:com.imaginary.home.cloud.device.PoweredDevice.java
static public void findPoweredDevicesForRelayWithChildren(@Nonnull ControllerRelay relay, @Nonnull Collection<Device> devices) throws PersistenceException { devices.addAll(findPoweredDevicesForRelay(relay)); Light.findLightssForRelayWithChildren(relay, devices); }
From source file:com.facebook.hiveio.mapreduce.output.WritingTool.java
/** * add string to collection//from w w w .ja v a 2s . co m * * @param conf Configuration * @param name to add * @param values values for collection */ private static void addToStringCollection(Configuration conf, String name, Collection<? extends String> values) { Collection<String> tmpfiles = conf.getStringCollection(name); tmpfiles.addAll(values); conf.setStrings(name, tmpfiles.toArray(new String[tmpfiles.size()])); }
From source file:net.mojodna.sprout.support.SproutUtils.java
/** * Gets a collection of methods declared in a specified range of a given * class' hierarchy.//from w w w . j a va 2s. c o m * * @param clazz Class to inspect. * @param upto Methods declared in this class and its subclasses will be * included. Any methods declared in superclasses will be ignored. * @return Collection of methods declared within the specified range. */ public static Collection<Method> getDeclaredMethods(Class clazz, final Class upto) { // collect methods to register (include methods for all classes up to and including this one) final Collection<Method> methods = new ArrayList(); while (!clazz.equals(upto.getSuperclass())) { methods.addAll(Arrays.asList(clazz.getDeclaredMethods())); clazz = clazz.getSuperclass(); } return methods; }
From source file:net.mojodna.searchable.SearchableBeanUtils.java
/** * Reflect on a set of classes to determine whether any fields have been * marked as default fields to search./*ww w . ja v a 2 s . co m*/ * * @param classes Classes to reflect on. * @return Array of default field names specified in all classes. */ public static String[] getDefaultFieldNames(final Class<? extends Searchable>[] classes) { final Collection<Object> defaultFields = new HashSet<Object>(); for (final Class<? extends Searchable> clazz : classes) { defaultFields.addAll(Arrays.asList(SearchableBeanUtils.getDefaultFieldNames(clazz))); } return SearchableUtils.toStringArray(defaultFields); }