Search in sources :

Example 81 with TreeSet

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);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method)

Example 82 with TreeSet

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);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method) PrimitiveTypeWrapper(org.mybatis.generator.api.dom.java.PrimitiveTypeWrapper)

Example 83 with TreeSet

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);
    }
}
Also used : TreeSet(java.util.TreeSet) FullyQualifiedJavaType(org.mybatis.generator.api.dom.java.FullyQualifiedJavaType) Method(org.mybatis.generator.api.dom.java.Method)

Example 84 with TreeSet

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());
}
Also used : PrimitiveLongIterator(org.neo4j.collection.primitive.PrimitiveLongIterator) LabelScanReader(org.neo4j.storageengine.api.schema.LabelScanReader) TreeSet(java.util.TreeSet) NodeLabelUpdate(org.neo4j.kernel.api.labelscan.NodeLabelUpdate) Test(org.junit.Test)

Example 85 with TreeSet

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);
                }
            }
        }
    }
}
Also used : ConstrainedTo(javax.ws.rs.ConstrainedTo) AutoDiscoverable(org.glassfish.jersey.internal.spi.AutoDiscoverable) ForcedAutoDiscoverable(org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable) TreeSet(java.util.TreeSet) Priority(javax.annotation.Priority) ForcedAutoDiscoverable(org.glassfish.jersey.internal.spi.ForcedAutoDiscoverable) LinkedList(java.util.LinkedList)

Aggregations

TreeSet (java.util.TreeSet)3785 ArrayList (java.util.ArrayList)833 Test (org.junit.Test)544 HashMap (java.util.HashMap)500 HashSet (java.util.HashSet)428 Set (java.util.Set)422 Map (java.util.Map)401 IOException (java.io.IOException)374 File (java.io.File)339 List (java.util.List)320 TreeMap (java.util.TreeMap)229 Iterator (java.util.Iterator)189 SortedSet (java.util.SortedSet)186 LinkedList (java.util.LinkedList)110 LinkedHashSet (java.util.LinkedHashSet)106 Date (java.util.Date)94 Collection (java.util.Collection)90 Comparator (java.util.Comparator)85 Test (org.testng.annotations.Test)81 Text (org.apache.hadoop.io.Text)79