use of java.util.IdentityHashMap in project rest.li by linkedin.
the class TemplateSpecGenerator method generateRecord.
private RecordTemplateSpec generateRecord(RecordDataSchema schema) {
final RecordTemplateSpec recordClass = new RecordTemplateSpec(schema);
recordClass.setNamespace(schema.getNamespace());
recordClass.setPackage(schema.getPackage());
recordClass.setClassName(schema.getName());
recordClass.setModifiers(ModifierSpec.PUBLIC);
registerClassTemplateSpec(schema, recordClass);
// processSchema included schemas first, so that unnamed classes will belong to the defining class
// instead of the current class
final List<NamedDataSchema> includes = schema.getInclude();
for (NamedDataSchema includedSchema : includes) {
processSchema(includedSchema, null, null);
}
final Map<CustomInfoSpec, Object> customInfoMap = new IdentityHashMap<CustomInfoSpec, Object>(schema.getFields().size() * 2);
for (RecordDataSchema.Field field : schema.getFields()) {
final ClassTemplateSpec fieldClass = processSchema(field.getType(), recordClass, field.getName());
final RecordTemplateSpec.Field newField = new RecordTemplateSpec.Field();
newField.setSchemaField(field);
newField.setType(fieldClass);
newField.setDataClass(determineDataClass(field.getType(), recordClass, field.getName()));
final CustomInfoSpec customInfo = getImmediateCustomInfo(field.getType());
if (customInfo != null) {
if (!customInfoMap.containsKey(customInfo)) {
customInfoMap.put(customInfo, null);
}
newField.setCustomInfo(customInfo);
}
recordClass.addField(newField);
}
return recordClass;
}
use of java.util.IdentityHashMap in project neo4j by neo4j.
the class CompilationFailureException method source.
private static String source(List<? extends Diagnostic<?>> diagnostics) {
Set<JavaFileObject> sources = null;
for (Diagnostic<?> diagnostic : diagnostics) {
Object source = diagnostic.getSource();
if (source instanceof JavaFileObject) {
JavaFileObject file = (JavaFileObject) source;
if (file.getKind() == JavaFileObject.Kind.SOURCE) {
if (sources == null) {
sources = Collections.newSetFromMap(new IdentityHashMap<JavaFileObject, Boolean>());
}
sources.add(file);
}
}
}
if (sources == null) {
return "";
}
StringBuilder result = new StringBuilder();
for (JavaFileObject source : sources) {
int pos = result.length();
result.append("\nSource file ").append(source.getName()).append(":\n");
try {
CharSequence content = source.getCharContent(true);
result.append(String.format("%4d: ", 1));
for (int line = 1, i = 0; i < content.length(); i++) {
char c = content.charAt(i);
result.append(c);
if (c == '\n') {
result.append(String.format("%4d: ", ++line));
}
}
} catch (IOException e) {
result.setLength(pos);
}
}
return result.toString();
}
use of java.util.IdentityHashMap in project netty by netty.
the class DefaultChannelPipeline method childExecutor.
private EventExecutor childExecutor(EventExecutorGroup group) {
if (group == null) {
return null;
}
Boolean pinEventExecutor = channel.config().getOption(ChannelOption.SINGLE_EVENTEXECUTOR_PER_GROUP);
if (pinEventExecutor != null && !pinEventExecutor) {
return group.next();
}
Map<EventExecutorGroup, EventExecutor> childExecutors = this.childExecutors;
if (childExecutors == null) {
// Use size of 4 as most people only use one extra EventExecutor.
childExecutors = this.childExecutors = new IdentityHashMap<EventExecutorGroup, EventExecutor>(4);
}
// Pin one of the child executors once and remember it so that the same child executor
// is used to fire events for the same channel.
EventExecutor childExecutor = childExecutors.get(group);
if (childExecutor == null) {
childExecutor = group.next();
childExecutors.put(group, childExecutor);
}
return childExecutor;
}
use of java.util.IdentityHashMap in project robovm by robovm.
the class AbstractMapTest method test_values.
/**
* java.util.AbstractMap#values()
*/
public void test_values() {
AbstractMap map1 = new HashMap(0);
assertSame("HashMap(0)", map1.values(), map1.values());
AbstractMap map2 = new HashMap(10);
assertSame("HashMap(10)", map2.values(), map2.values());
Map map3 = Collections.EMPTY_MAP;
assertSame("EMPTY_MAP", map3.values(), map3.values());
AbstractMap map4 = new IdentityHashMap(1);
assertSame("IdentityHashMap", map4.values(), map4.values());
AbstractMap map5 = new LinkedHashMap(122);
assertSame("IdentityHashMap", map5.values(), map5.values());
AbstractMap map6 = new TreeMap();
assertSame("TreeMap", map6.values(), map6.values());
AbstractMap map7 = new WeakHashMap();
assertSame("WeakHashMap", map7.values(), map7.values());
}
use of java.util.IdentityHashMap in project robovm by robovm.
the class IdentityHashMapTest method test_Constructor.
/**
* java.util.IdentityHashMap#IdentityHashMap()
*/
public void test_Constructor() {
// Test for method java.util.IdentityHashMap()
new Support_MapTest2(new IdentityHashMap()).runTest();
IdentityHashMap hm2 = new IdentityHashMap();
assertEquals("Created incorrect IdentityHashMap", 0, hm2.size());
}
Aggregations