use of java.util.TreeSet in project generator by mybatis.
the class InsertMethodGenerator method addInterfaceElements.
@Override
public void addInterfaceElements(Interface interfaze) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (context.getPlugins().clientInsertMethodGenerated(method, interfaze, introspectedTable)) {
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(method);
}
}
use of java.util.TreeSet in project generator by mybatis.
the class InsertSelectiveMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
FullyQualifiedJavaType returnType = method.getReturnType();
StringBuilder sb = new StringBuilder();
if (returnType != null) {
//$NON-NLS-1$
sb.append("Object newKey = ");
}
sb.append(daoTemplate.getInsertMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getInsertSelectiveStatementId(), //$NON-NLS-1$
"record"));
method.addBodyLine(sb.toString());
if (returnType != null) {
if ("Object".equals(returnType.getShortName())) {
//$NON-NLS-1$
// no need to cast if the return type is Object
//$NON-NLS-1$
method.addBodyLine("return newKey;");
} else {
sb.setLength(0);
if (returnType.isPrimitive()) {
PrimitiveTypeWrapper ptw = returnType.getPrimitiveTypeWrapper();
//$NON-NLS-1$
sb.append("return ((");
sb.append(ptw.getShortName());
//$NON-NLS-1$
sb.append(") newKey");
//$NON-NLS-1$
sb.append(").");
sb.append(ptw.getToPrimitiveMethod());
sb.append(';');
} else {
//$NON-NLS-1$
sb.append("return (");
sb.append(returnType.getShortName());
//$NON-NLS-1$
sb.append(") newKey;");
}
method.addBodyLine(sb.toString());
}
}
if (context.getPlugins().clientInsertSelectiveMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
use of java.util.TreeSet in project generator by mybatis.
the class SelectByExampleWithBLOBsMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
if (generateForJava5) {
method.addSuppressTypeWarningsAnnotation();
}
StringBuilder sb = new StringBuilder();
sb.append(method.getReturnType().getShortName());
//$NON-NLS-1$
sb.append(" list = ");
sb.append(daoTemplate.getQueryForListMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getSelectByExampleWithBLOBsStatementId(), //$NON-NLS-1$
"example"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return list;");
if (context.getPlugins().clientSelectByExampleWithBLOBsMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
use of java.util.TreeSet in project neo4j by neo4j.
the class LabelScanStoreTest method shouldFindDecentAmountOfNodesForALabel.
@Test
public void shouldFindDecentAmountOfNodesForALabel() throws Exception {
// GIVEN
// 16 is the magic number of the page iterator
// 32 is the number of nodes in each lucene document
final int labelId = 1, nodeCount = 32 * 16 + 10;
start();
write(new PrefetchingIterator<NodeLabelUpdate>() {
private int i = -1;
@Override
protected NodeLabelUpdate fetchNextOrNull() {
return ++i < nodeCount ? labelChanges(i, NO_LABELS, new long[] { labelId }) : null;
}
});
// WHEN
Set<Long> nodeSet = new TreeSet<>();
LabelScanReader reader = store.newReader();
PrimitiveLongIterator nodes = reader.nodesWithLabel(labelId);
while (nodes.hasNext()) {
nodeSet.add(nodes.next());
}
reader.close();
// THEN
assertEquals("Found gaps in node id range: " + gaps(nodeSet, nodeCount), nodeCount, nodeSet.size());
}
use of java.util.TreeSet in project jersey by jersey.
the class CommonConfig method configureAutoDiscoverableProviders.
/**
* Configure {@link AutoDiscoverable auto-discoverables} in the injection manager.
*
* @param injectionManager locator in which the auto-discoverables should be configured.
* @param forcedOnly defines whether all or only forced auto-discoverables should be configured.
*/
public void configureAutoDiscoverableProviders(final InjectionManager injectionManager, final boolean forcedOnly) {
// Check whether meta providers have been initialized for a config this config has been loaded from.
if (!disableMetaProviderConfiguration) {
final Set<AutoDiscoverable> providers = new TreeSet<>((o1, o2) -> {
final int p1 = o1.getClass().isAnnotationPresent(Priority.class) ? o1.getClass().getAnnotation(Priority.class).value() : Priorities.USER;
final int p2 = o2.getClass().isAnnotationPresent(Priority.class) ? o2.getClass().getAnnotation(Priority.class).value() : Priorities.USER;
return (p1 < p2 || p1 == p2) ? -1 : 1;
});
// Forced (always invoked).
final List<ForcedAutoDiscoverable> forcedAutoDiscroverables = new LinkedList<>();
for (Class<ForcedAutoDiscoverable> forcedADType : ServiceFinder.find(ForcedAutoDiscoverable.class, true).toClassArray()) {
forcedAutoDiscroverables.add(injectionManager.createAndInitialize(forcedADType));
}
providers.addAll(forcedAutoDiscroverables);
// Regular.
if (!forcedOnly) {
providers.addAll(Providers.getProviders(injectionManager, AutoDiscoverable.class));
}
for (final AutoDiscoverable autoDiscoverable : providers) {
final ConstrainedTo constrainedTo = autoDiscoverable.getClass().getAnnotation(ConstrainedTo.class);
if (constrainedTo == null || type.equals(constrainedTo.value())) {
try {
autoDiscoverable.configure(this);
} catch (final Exception e) {
LOGGER.log(Level.FINE, LocalizationMessages.AUTODISCOVERABLE_CONFIGURATION_FAILED(autoDiscoverable.getClass()), e);
}
}
}
}
}
Aggregations