Java Code Examples for java.util.Set#getClass()
The following examples show how to use
java.util.Set#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jsonya.java From brooklyn-server with Apache License 2.0 | 6 votes |
protected Object apply(Object input, Set<Object> stack) { if (input==null) return applyNull(stack); if (isPrimitiveOrBoxer(input.getClass())) return applyPrimitiveOrBoxer(input, stack); if (input instanceof String) return applyString((String)input, stack); stack = new HashSet<Object>(stack); if (!stack.add(input)) // fail if object is self-recursive; don't even try toString as that is dangerous // (extra measure of safety, since maps and lists generally fail elsewhere with recursive entries, // eg in hashcode or toString) return "[REF_ANCESTOR:"+stack.getClass()+"]"; if (input instanceof Collection<?>) return applyCollection( (Collection<?>)input, stack ); if (input instanceof Map<?,?>) return applyMap( (Map<?,?>)input, stack ); return applyOther(input, stack); }
Example 2
Source File: ObjectDumper.java From symja_android_library with GNU General Public License v3.0 | 6 votes |
private <E> void appendSet(Set<E> set, DumpMode dumpMode, int depth) { Class<?> collectionClass = set.getClass(); result.append(collectionClass.getName()).append("{"); if (set.isEmpty()) { result.append(EMPTY); } else { result.append("\n"); for (E element : set) { makeIndent(depth + 1); appendObject(element, getElementDumpMode(element, dumpMode), depth + 1); result.append("\n"); } makeIndent(depth); } result.append("}"); }
Example 3
Source File: TermOffsetFunction.java From datawave with Apache License 2.0 | 5 votes |
@Override public Tuple3<Key,Document,Map<String,Object>> apply(Tuple2<Key,Document> from) { Document merged = from.second(); Map<String,Object> map = new HashMap<>(); Attribute<?> docKeyAttr = merged.get(Document.DOCKEY_FIELD_NAME); // gather the set of doc keys Set<Key> docKeys = new HashSet<>(); if (docKeyAttr == null) { docKeys.add(from.first()); } else if (docKeyAttr instanceof DocumentKey) { docKeys.add(((DocumentKey) docKeyAttr).getDocKey()); } else if (docKeyAttr instanceof Attributes) { for (Attribute<?> docKey : ((Attributes) docKeyAttr).getAttributes()) { if (docKey instanceof DocumentKey) { docKeys.add(((DocumentKey) docKey).getDocKey()); } else { throw new IllegalStateException("Unexpected sub-Attribute type for " + Document.DOCKEY_FIELD_NAME + ": " + docKey.getClass()); } } } else { throw new IllegalStateException("Unexpected Attribute type for " + Document.DOCKEY_FIELD_NAME + ": " + docKeys.getClass()); } map.putAll(tfPopulator.getContextMap(from.first(), docKeys)); merged.putAll(tfPopulator.document(), false); return Tuples.tuple(from.first(), merged, map); }
Example 4
Source File: ReflectClassDemo03.java From javacore with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
public static void main(String[] args) { Class c = "foo".getClass(); System.out.println(c.getCanonicalName()); Class c2 = ReflectClassDemo03.E.A.getClass(); System.out.println(c2.getCanonicalName()); byte[] bytes = new byte[1024]; Class c3 = bytes.getClass(); System.out.println(c3.getCanonicalName()); Set<String> set = new HashSet<>(); Class c4 = set.getClass(); System.out.println(c4.getCanonicalName()); }