List of usage examples for java.util Set add
boolean add(E e);
From source file:Main.java
public static void removeInvalidAttributes(Element element, String... validAttributeNames) { Set<String> validNames = new HashSet<String>(); for (String name : validAttributeNames) { validNames.add(name); }//from w ww . j a v a 2s.c om boolean elementModified = false; NamedNodeMap nnm = element.getAttributes(); for (int i = 0; i < nnm.getLength(); i++) { String attributeName = nnm.item(i).getNodeName(); if (!validNames.contains(attributeName)) { element.removeAttribute(attributeName); elementModified = true; } } if (elementModified) { flagDocumentAsCorrected(element); } }
From source file:com.astamuse.asta4d.web.form.flow.ext.ExcludingFieldRetrievableFormHelper.java
public static final void copyIncludeFieldsOnly(Object targetForm, ExcludingFieldRetrievableForm... froms) { try {/*w ww . j a va 2s. c o m*/ for (ExcludingFieldRetrievableForm from : froms) { List<AnnotatedPropertyInfo> fromProps = AnnotatedPropertyUtil.retrieveProperties(from.getClass()); String[] excludes = from.getExcludeFields(); Set<String> set = new HashSet<>(); for (String s : excludes) { set.add(s); } for (AnnotatedPropertyInfo p : fromProps) { // do not copy excluded fields if (set.contains(p.getName())) { continue; } AnnotatedPropertyUtil.assignValueByName(targetForm, p.getName(), p.retrieveValue(from)); } } } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:StringUtil.java
/** * <p> Converts a char array to a Set. Puts all characters in the array to a Set. * * @param charArray an array of <CODE>char</CODE>s * @return a <code>set</code> containing all characters in the char array *//*from www . ja v a 2 s .c om*/ public static Set convertToSet(char[] charArray) { // Result hashset Set resultSet = new HashSet(); for (int i = 0; i < charArray.length; i++) { resultSet.add(new Character(charArray[i])); } // Return result return resultSet; }
From source file:Main.java
public static <K, V> void addToMapSet(K key, V value, Map<K, Set<V>> map) { Set<V> set = map.get(key); if (set == null) { set = new HashSet<V>(); map.put(key, set);/*from www . j av a 2 s .c om*/ } set.add(value); }
From source file:Main.java
public static Set<Long> toSet(long... array) { if (isEmpty(array)) { return new HashSet<>(0); }/*from w ww. j av a2s. com*/ Set<Long> set = new HashSet<>(array.length); for (long l : array) { set.add(new Long(l)); } return set; }
From source file:edu.mayo.cts2.uriresolver.security.UserDetailsServiceImpl.java
private static boolean importUser() throws NamingException { boolean importedUsers = false; String creds = (String) context.lookup("uriResolverDatabaseCredentials"); if (creds != null) { String[] arr = creds.split("\\s"); String username = arr[0].trim(); String password = arr[1].trim(); logger.info("ACCOUNT: " + username + "\t" + password); Set<GrantedAuthority> authList = new HashSet<GrantedAuthority>(); authList.add(new SimpleGrantedAuthority("ROLE_USER")); UserDetails user = new UserDetailsImpl(username, password, authList); userRepository.put(username, user); importedUsers = true;/* w ww. ja v a2 s. c om*/ } return importedUsers; }
From source file:gov.nih.nci.cabig.caaers.CollectionUtil.java
public static List<Integer> subtract(Collection<Integer> a, Collection<Integer> b) { Set<Integer> y = new HashSet<Integer>(b); Set<Integer> z = new HashSet<Integer>(); for (Integer i : a) { if (y.add(i)) z.add(i);//w w w .j a va 2s . co m } return new ArrayList(z); }
From source file:com.qwazr.extractor.ExtractorServer.java
public static void load(AbstractServer server, File data_directory, Set<Class<?>> restClasses) throws IOException { ParserManager.load();//from w ww .jav a 2 s . c om if (restClasses != null) restClasses.add(TextExtractorApplication.class); }
From source file:io.github.moosbusch.lumpi.util.FormUtil.java
public static Set<Class<?>> getDefaultIgnoredTypes() { Set<Class<?>> result = new HashSet<>(); result.add(Class.class); result.add(ClassLoader.class); return result; }
From source file:Main.java
public static <K, V> Set<V> lookup(Map<K, V> map, Collection<K> keys) { Set<V> result = new LinkedHashSet<V>(); for (K key : keys) { V e = map.get(key);/*from ww w . j a va2s . c o m*/ if (e != null) { result.add(e); } } return result; }