List of usage examples for java.util IdentityHashMap IdentityHashMap
public IdentityHashMap()
From source file:Main.java
/** * Create a new identityHashSet.//www . j a v a 2 s . c o m * @return */ public static <E> Set<E> identityHashSet() { return Collections.newSetFromMap(new IdentityHashMap<E, Boolean>()); }
From source file:Main.java
/** * Convenient method to create {@link IdentityHashMap} instance. * //ww w . j a v a 2s .com * @param <K> * key type * @param <V> * value type * @return created {@link IdentityHashMap} */ public static <K, V> Map<K, V> newIdentityHashMap() { return new IdentityHashMap<K, V>(); }
From source file:com.netflix.config.util.ConfigurationUtils.java
/** * Convert CombinedConfiguration into {@link ConcurrentCompositeConfiguration} as the later has better performance * and thread safety. //from w w w .ja v a 2s. c o m * * @param config Configuration to be converted */ public static ConcurrentCompositeConfiguration convertToConcurrentCompositeConfiguration( CombinedConfiguration config) { ConcurrentCompositeConfiguration root = new ConcurrentCompositeConfiguration(); IdentityHashMap<Configuration, String> reverseMap = new IdentityHashMap<Configuration, String>(); for (String name : (Set<String>) config.getConfigurationNames()) { Configuration child = config.getConfiguration(name); reverseMap.put(child, name); } for (int i = 0; i < config.getNumberOfConfigurations(); i++) { Configuration child = config.getConfiguration(i); String name = reverseMap.get(child); if (child instanceof CombinedConfiguration) { CombinedConfiguration combinedConf = (CombinedConfiguration) child; ConcurrentCompositeConfiguration newConf = convertToConcurrentCompositeConfiguration(combinedConf); root.addConfiguration(newConf, name); } else { Configuration conf = new ConcurrentMapConfiguration(child); root.addConfiguration((AbstractConfiguration) conf, name); } } return root; }
From source file:org.unitils.mock.core.proxy.CloneUtil.java
/** * Creates a deep clone of the given object. If for some reason, the clone cannot be made, a warning is logged * and the object itself will be returned. This is also true for all inner objects. If an inner object * cannot be cloned, the object itself is used instead. * * @param object The object to clone/*from w w w . j av a 2s . co m*/ * @return The cloned instance */ @SuppressWarnings({ "unchecked" }) public static <T> T createDeepClone(T object) { try { return (T) cloneObject(object, new IdentityHashMap<Object, Object>()); } catch (Throwable e) { throw new UnitilsException("Unexpected exception during cloning of " + object, e); } }
From source file:org.dimitrovchi.conf.service.ServiceParameterUtils.java
static AnnotationParameters annotationParameters() { final Class<?>[] stack = ClassResolver.CLASS_RESOLVER.getClassContext(); final Class<?> caller = stack[3]; final List<Class<? extends Annotation>> interfaces = new ArrayList<>(); Class<?> topCaller = null; for (int i = 3; i < stack.length && caller.isAssignableFrom(stack[i]); i++) { final Class<?> c = stack[i]; topCaller = stack[i];//from w w w . j a va 2 s . c o m if (c.getTypeParameters().length != 0) { final TypeVariable<? extends Class<?>> var = c.getTypeParameters()[0]; final List<Class<? extends Annotation>> bounds = new ArrayList<>(var.getBounds().length); for (final Type type : var.getBounds()) { if (type instanceof Class<?> && ((Class<?>) type).isAnnotation()) { bounds.add((Class) type); } } if (bounds.size() > interfaces.size()) { interfaces.clear(); interfaces.addAll(bounds); } } } final Map<Class<? extends Annotation>, List<Annotation>> annotationMap = new IdentityHashMap<>(); for (int i = 3; i < stack.length && caller.isAssignableFrom(stack[i]); i++) { final Class<?> c = stack[i]; for (final Class<? extends Annotation> itf : interfaces) { final Annotation annotation = c.getAnnotation(itf); if (annotation != null) { List<Annotation> annotationList = annotationMap.get(itf); if (annotationList == null) { annotationMap.put(itf, annotationList = new ArrayList<>()); } annotationList.add(0, annotation); } } } return new AnnotationParameters(topCaller, interfaces, annotationMap); }
From source file:com.espertech.esper.filter.FilterParamIndexStringRangeBase.java
protected FilterParamIndexStringRangeBase(FilterSpecLookupable lookupable, FilterOperator filterOperator) { super(filterOperator, lookupable); ranges = new TreeMap<StringRange, EventEvaluator>(new StringRangeComparator()); rangesNullEndpoints = new IdentityHashMap<StringRange, EventEvaluator>(); rangesRWLock = new ReentrantReadWriteLock(); }
From source file:IdentitySet.java
/** * Create an IdentitySet with default sizing. */ public IdentitySet() { this.map = new IdentityHashMap(); }
From source file:org.grails.plugin.nativefinders.NativeFinderHandler.java
public NativeFinderHandler(GrailsDomainClass domainClass, SessionFactory sessionFactory) { this.domainClass = domainClass; this.sessionFactory = sessionFactory; queryCache = new IdentityHashMap<ClosureExpression, String>(); }
From source file:com.espertech.esper.filter.FilterParamIndexDoubleRangeBase.java
protected FilterParamIndexDoubleRangeBase(FilterSpecLookupable lookupable, FilterOperator filterOperator) { super(filterOperator, lookupable); ranges = new TreeMap<DoubleRange, EventEvaluator>(new DoubleRangeComparator()); rangesNullEndpoints = new IdentityHashMap<DoubleRange, EventEvaluator>(); rangesRWLock = new ReentrantReadWriteLock(); }
From source file:org.sonar.api.checks.checkers.AnnotationCheckerFactory.java
public Map<Check, CHECKER> create() { Map<String, Class<CHECKER>> classesByKey = getClassesByKey(checkerClasses); Map<Check, CHECKER> map = new IdentityHashMap<Check, CHECKER>(); for (Check check : profile.getChecks(repositoryKey)) { Class<CHECKER> clazz = classesByKey.get(check.getTemplateKey()); if (clazz != null) { CHECKER checker = instantiate(check, clazz); if (checker != null) { map.put(check, checker); }//from w w w . ja va 2 s . c o m } } return map; }