Java Examples for java.util.Arrays

The following java examples will help you to understand the usage of java.util.Arrays. These source code samples are taken from different open source projects.

Example 1
Project: sosies-generator-master  File: AbstractCollectionTest.java View source code
/** 
     * Tests [email protected] Collection#addAll(Collection)}.
     */
@Test(timeout = 1000)
public void testCollectionAddAll() {
    fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(), this, "testCollectionAddAll");
    if (!(isAddSupported())) {
        return;
    }
    resetEmpty();
    resetEmpty();
    E[] elements = getFullElements();
    boolean r = getCollection().addAll(java.util.Arrays.asList(elements));
    getConfirmed().addAll(java.util.Arrays.asList(elements));
    verify();
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4544, r);
    for (final E element : elements) {
        fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4546, getCollection(), 4545, getCollection().contains(element));
    }
    resetFull();
    int size = getCollection().size();
    elements = getOtherElements();
    r = getCollection().addAll(java.util.Arrays.asList(elements));
    getConfirmed().addAll(java.util.Arrays.asList(elements));
    verify();
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4547, r);
    for (final E element : elements) {
        fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4549, getCollection(), 4548, getCollection().contains(element));
    }
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4550, (size + (elements.length)));
    fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4552, getCollection(), 4551, getCollection().size());
    resetFull();
    size = getCollection().size();
    r = getCollection().addAll(java.util.Arrays.asList(getFullElements()));
    getConfirmed().addAll(java.util.Arrays.asList(getFullElements()));
    verify();
    if (r) {
        fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4553, (size < (getCollection().size())));
    } else {
        fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4554, size);
        fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(), 4556, getCollection(), 4555, getCollection().size());
    }
    fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread());
}
Example 2
Project: Time4J-master  File: EthiopicNumberTest.java View source code
@Parameters(name = "{index}: [value={0} / numeral={1}")
public static Iterable<Object[]> data() {
    return Arrays.asList(new Object[][] { { 1, "፩" }, { 10, "፲" }, { 100, "፻" }, { 1000, "፲፻" }, { 10000, "፼" }, { 100000, "፲፼" }, { 1000000, "፻፼" }, { 10000000, "፲፻፼" }, { 100000000, "፼፼" }, { 100010000, "፼፩፼" }, { 100100000, "፼፲፼" }, { 100200000, "፼፳፼" }, { 100110000, "፼፲፩፼" }, { 1, "፩" }, { 11, "፲፩" }, { 111, "፻፲፩" }, { 1111, "፲፩፻፲፩" }, { 11111, "፼፲፩፻፲፩" }, { 111111, "፲፩፼፲፩፻፲፩" }, { 1111111, "፻፲፩፼፲፩፻፲፩" }, { 11111111, "፲፩፻፲፩፼፲፩፻፲፩" }, { 111111111, "፼፲፩፻፲፩፼፲፩፻፲፩" }, { 1111111111, "፲፩፼፲፩፻፲፩፼፲፩፻፲፩" }, { 1, "፩" }, { 12, "፲፪" }, { 123, "፻፳፫" }, { 1234, "፲፪፻፴፬" }, { 12345, "፼፳፫፻፵፭" }, { 7654321, "፯፻፷፭፼፵፫፻፳፩" }, { 17654321, "፲፯፻፷፭፼፵፫፻፳፩" }, { 51615131, "፶፩፻፷፩፼፶፩፻፴፩" }, { 15161513, "፲፭፻፲፮፼፲፭፻፲፫" }, { 10101011, "፲፻፲፼፲፻፲፩" }, { 101, "፻፩" }, { 1001, "፲፻፩" }, { 1010, "፲፻፲" }, { 1011, "፲፻፲፩" }, { 1100, "፲፩፻" }, { 1101, "፲፩፻፩" }, { 1111, "፲፩፻፲፩" }, { 10001, "፼፩" }, { 10010, "፼፲" }, { 10100, "፼፻" }, { 10101, "፼፻፩" }, { 10110, "፼፻፲" }, { 10111, "፼፻፲፩" }, { 100001, "፲፼፩" }, { 100010, "፲፼፲" }, { 100011, "፲፼፲፩" }, { 100100, "፲፼፻" }, { 101010, "፲፼፲፻፲" }, { 1000001, "፻፼፩" }, { 1000101, "፻፼፻፩" }, { 1000100, "፻፼፻" }, { 1010000, "፻፩፼" }, { 1010001, "፻፩፼፩" }, { 1100001, "፻፲፼፩" }, { 1010101, "፻፩፼፻፩" }, { 101010101, "፼፻፩፼፻፩" }, { 10000, "፼" }, { 100000, "፲፼" }, { 1000000, "፻፼" }, { 10000000, "፲፻፼" }, { 100000000, "፼፼" }, { 1000000000, "፲፼፼" }, { 100010000, "፼፩፼" }, { 100010100, "፼፩፼፻" }, { 101010100, "፼፻፩፼፻" }, { 3, "፫" }, { 30, "፴" }, { 33, "፴፫" }, { 303, "፫፻፫" }, { 3003, "፴፻፫" }, { 3030, "፴፻፴" }, { 3033, "፴፻፴፫" }, { 3300, "፴፫፻" }, { 3303, "፴፫፻፫" }, { 3333, "፴፫፻፴፫" }, { 30003, "፫፼፫" }, { 30303, "፫፼፫፻፫" }, { 300003, "፴፼፫" }, { 303030, "፴፼፴፻፴" }, { 3000003, "፫፻፼፫" }, { 3000303, "፫፻፼፫፻፫" }, { 3030003, "፫፻፫፼፫" }, { 3300003, "፫፻፴፼፫" }, { 3030303, "፫፻፫፼፫፻፫" }, { 303030303, "፫፼፫፻፫፼፫፻፫" }, { 333333333, "፫፼፴፫፻፴፫፼፴፫፻፴፫" } });
}
Example 3
Project: j2objc-master  File: ArraysTest.java View source code
/**
	 * @tests java.util.Arrays#asList(java.lang.Object[])
	 */
public void test_asList$Ljava_lang_Object() {
    // Test for method java.util.List
    // java.util.Arrays.asList(java.lang.Object [])
    List convertedList = Arrays.asList(objectArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == objectArray[counter]);
    }
    convertedList.set(50, new Integer(1000));
    assertTrue("set/get did not work on coverted list", convertedList.get(50).equals(new Integer(1000)));
    convertedList.set(50, new Integer(50));
    new Support_UnmodifiableCollectionTest("", convertedList).runTest();
    Object[] myArray = (Object[]) (objectArray.clone());
    myArray[30] = null;
    myArray[60] = null;
    convertedList = Arrays.asList(myArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == myArray[counter]);
    }
    try {
        Arrays.asList((Object[]) null);
        fail("asList with null arg didn't throw NPE");
    } catch (NullPointerException e) {
    }
}
Example 4
Project: seasar2-master  File: MessageResourceBundleFactoryTest.java View source code
/**
     * @throws Exception
     */
public void testCalcurateBundleNames() throws Exception {
    // 言語のみ
    String[] bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, Locale.JAPANESE);
    List expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "_ja" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // 言語と国
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("ja", "JP"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "_ja", BASE_NAME + "_ja_JP" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // 言語と国とバリアント
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("ja", "JP", "WIN"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "_ja", BASE_NAME + "_ja_JP", BASE_NAME + "_ja_JP_WIN" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // 言語とバリアント
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("ja", "", "WIN"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "_ja", BASE_NAME + "_ja__WIN" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // 国とバリアント
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("", "JP", "WIN"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "__JP", BASE_NAME + "__JP_WIN" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // 国のみ
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("", "JP"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "__JP" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
    // バリアントのみ
    bundleNames = MessageResourceBundleFactory.calcurateBundleNames(BASE_NAME, new Locale("", "", "WIN"));
    expected = java.util.Arrays.asList(new String[] { BASE_NAME, BASE_NAME + "___WIN" });
    assertEquals(expected, java.util.Arrays.asList(bundleNames));
}
Example 5
Project: mldht-master  File: SortedCoWSet.java View source code
public boolean add(T toAdd) {
    synchronized (copyOnWriteLock) {
        int insertIndex = java.util.Arrays.binarySearch(storage, toAdd, comparator);
        if (insertIndex >= 0) {
            // already present
            return false;
        }
        insertIndex = -(insertIndex + 1);
        T[] newStorage = java.util.Arrays.copyOf(storage, storage.length + 1);
        if (newStorage.length > 1)
            System.arraycopy(newStorage, insertIndex, newStorage, insertIndex + 1, newStorage.length - insertIndex - 1);
        newStorage[insertIndex] = toAdd;
        storage = newStorage;
    }
    return true;
}
Example 6
Project: ARTPart-master  File: Main.java View source code
public static void main(String[] args) throws Exception {
    // These charsets must be provided; anything else is optional.
    List<String> standardCharsets = Arrays.asList("US-ASCII", "ISO-8859-1", "UTF-8", "UTF-16BE", "UTF-16LE", "UTF-16");
    SortedMap<String, Charset> all = Charset.availableCharsets();
    Set<String> needed = new HashSet<String>(standardCharsets);
    for (Map.Entry<String, Charset> e : all.entrySet()) {
        String canonicalName = e.getKey();
        needed.remove(canonicalName);
    }
    System.out.println("Missing: " + needed);
}
Example 7
Project: android-sdk-sources-for-api-level-23-master  File: ArraysTest.java View source code
/**
     * java.util.Arrays#asList(java.lang.Object[])
     */
public void test_asList$Ljava_lang_Object() {
    // Test for method java.util.List
    // java.util.Arrays.asList(java.lang.Object [])
    List convertedList = Arrays.asList(objectArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == objectArray[counter]);
    }
    convertedList.set(50, new Integer(1000));
    assertTrue("set/get did not work on coverted list", convertedList.get(50).equals(new Integer(1000)));
    convertedList.set(50, new Integer(50));
    new Support_UnmodifiableCollectionTest("", convertedList).runTest();
    Object[] myArray = (Object[]) (objectArray.clone());
    myArray[30] = null;
    myArray[60] = null;
    convertedList = Arrays.asList(myArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == myArray[counter]);
    }
    try {
        Arrays.asList((Object[]) null);
        fail("asList with null arg didn't throw NPE");
    } catch (NullPointerException e) {
    }
}
Example 8
Project: android_platform_libcore-master  File: ArraysTest.java View source code
/**
     * java.util.Arrays#asList(java.lang.Object[])
     */
public void test_asList$Ljava_lang_Object() {
    // Test for method java.util.List
    // java.util.Arrays.asList(java.lang.Object [])
    List convertedList = Arrays.asList(objectArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == objectArray[counter]);
    }
    convertedList.set(50, new Integer(1000));
    assertTrue("set/get did not work on coverted list", convertedList.get(50).equals(new Integer(1000)));
    convertedList.set(50, new Integer(50));
    new Support_UnmodifiableCollectionTest("", convertedList).runTest();
    Object[] myArray = (Object[]) (objectArray.clone());
    myArray[30] = null;
    myArray[60] = null;
    convertedList = Arrays.asList(myArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == myArray[counter]);
    }
    try {
        Arrays.asList((Object[]) null);
        fail("asList with null arg didn't throw NPE");
    } catch (NullPointerException e) {
    }
}
Example 9
Project: android-libcore64-master  File: ArraysTest.java View source code
/**
     * java.util.Arrays#asList(java.lang.Object[])
     */
public void test_asList$Ljava_lang_Object() {
    // Test for method java.util.List
    // java.util.Arrays.asList(java.lang.Object [])
    List convertedList = Arrays.asList(objectArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == objectArray[counter]);
    }
    convertedList.set(50, new Integer(1000));
    assertTrue("set/get did not work on coverted list", convertedList.get(50).equals(new Integer(1000)));
    convertedList.set(50, new Integer(50));
    new Support_UnmodifiableCollectionTest("", convertedList).runTest();
    Object[] myArray = (Object[]) (objectArray.clone());
    myArray[30] = null;
    myArray[60] = null;
    convertedList = Arrays.asList(myArray);
    for (int counter = 0; counter < arraySize; counter++) {
        assertTrue("Array and List converted from array do not contain identical elements", convertedList.get(counter) == myArray[counter]);
    }
    try {
        Arrays.asList((Object[]) null);
        fail("asList with null arg didn't throw NPE");
    } catch (NullPointerException e) {
    }
}
Example 10
Project: sonar-java-master  File: ReplaceLambdaByMethodRefCheck_no_version.java View source code
void fun() {
    IntStream.range(1, 5).map(( x) -> x * x).map(// Noncompliant {{Replace this lambda with a method reference. (sonar.java.source not set. Assuming 8 or greater.)}}
     x -> square(x)).map(// Noncompliant
     x -> {
        return square(x);
    }).map(//Compliant
    this::square).forEach(System.out::println);
    // Noncompliant
    IntStream.range(1, 5).forEach( x -> System.out.println(x));
    // Noncompliant
    IntStream.range(1, 5).forEach(// Noncompliant
     x -> {
        System.out.println(x);
    });
    // Compliant
    IntStream.range(1, 5).forEach( x -> {
        return;
    });
    // Compliant
    Arrays.asList("bar").stream().filter( string -> string.startsWith("b"));
    // Compliant
    Arrays.asList(new A()).stream().filter( a -> a.coolerThan(0, a));
}
Example 11
Project: eclipselink.runtime-master  File: ContainerCloningTest.java View source code
public void test() {
    ContainerPolicy cp = new CollectionContainerPolicy();
    cp.setContainerClass(ClassConstants.ArrayList_class);
    Collection originalC = java.util.Arrays.asList(new Employee());
    Collection cloneC = (Collection) cp.cloneFor(originalC);
    cp = new MapContainerPolicy();
    cp.setContainerClass(java.util.WeakHashMap.class);
    Map originalM = new java.util.WeakHashMap();
    originalM.put(1, 2);
    Map cloneM = (Map) cp.cloneFor(originalM);
    if ((originalC == cloneC) || (originalC.size() != cloneC.size())) {
        throw new TestErrorException("Cloned Collections are not copies.");
    }
    if ((originalM == cloneM) || (originalM.size() != cloneM.size())) {
        throw new TestErrorException("Cloned Maps are not copies.");
    }
    if (!originalC.iterator().next().equals(cloneC.iterator().next())) {
        throw new TestErrorException("Cloned Collections are not the same.");
    }
    if (!originalM.get(1).equals(cloneM.get(1))) {
        throw new TestErrorException("Cloned Maps are not the same.");
    }
}
Example 12
Project: hank-master  File: TestLeftPaddedIdentityHasher.java View source code
@Test
public void testPad() throws Exception {
    LeftPaddedIdentityHasher hasher = new LeftPaddedIdentityHasher();
    byte[] result = new byte[4];
    hasher.hash(ByteBuffer.wrap(new byte[] { 1, 2 }), 4, result);
    assertTrue(Arrays.equals(new byte[] { 0, 0, 1, 2 }, result));
    byte[] result2 = new byte[4];
    hasher.hash(ByteBuffer.wrap(new byte[] { 1, 2, 3, 4 }), 4, result2);
    assertTrue(Arrays.equals(new byte[] { 1, 2, 3, 4 }, result2));
    try {
        byte[] result3 = new byte[4];
        hasher.hash(ByteBuffer.wrap(new byte[] { 1, 2, 3, 4, 5 }), 4, result3);
        fail();
    } catch (Exception e) {
    }
}
Example 13
Project: LambdaDojo-master  File: S204LambdaInsteadOfAnonClass.java View source code
// 2-4 Lambda 式で書きかえてみましょう
private void rewriteByLambda() {
    Function<String, Integer> function = new Function<String, Integer>() {

        @Override
        public Integer apply(String word) {
            return word.length();
        }
    };
    List<String> words = Arrays.asList("one thing was certain that the white kitten had had nothing to do with it".split(" "));
    double average = 0.0;
    for (String word : words) {
        average += function.apply(word);
    }
    average /= words.size();
    System.out.println("Average: " + average);
}
Example 14
Project: breakout-master  File: ReduxTest.java View source code
@Test
public void test1() {
    Store<Number> store = Redux.applyMiddleware(Arrays.asList(new Logger()), Redux.createStore(new Reducer<Number>() {

        @Override
        public Number apply(Number state, Action action) {
            return action.type == "INCREMENT" ? state.intValue() + 1 : state;
        }
    }, 0));
    IntHolder eventCount = new IntHolder();
    Runnable unsub = store.subscribe(() -> eventCount.value++);
    Assert.assertEquals(0, store.getState());
    Assert.assertEquals(0, eventCount.value);
    store.dispatch(new Action("INCREMENT"));
    Assert.assertEquals(1, store.getState());
    Assert.assertEquals(1, eventCount.value);
    unsub.run();
    store.dispatch(new Action("INCREMENT"));
    Assert.assertEquals(2, store.getState());
    Assert.assertEquals(1, eventCount.value);
}
Example 15
Project: java8-tutorial-master  File: Streams8.java View source code
public static void main(String[] args) {
    Arrays.asList("a1", "a2", "a3").stream().findFirst().ifPresent(System.out::println);
    Stream.of("a1", "a2", "a3").map( s -> s.substring(1)).mapToInt(Integer::parseInt).max().ifPresent(System.out::println);
    IntStream.range(1, 4).mapToObj( i -> "a" + i).forEach(System.out::println);
    Arrays.stream(new int[] { 1, 2, 3 }).map( n -> 2 * n + 1).average().ifPresent(System.out::println);
    Stream.of(1.0, 2.0, 3.0).mapToInt(Double::intValue).mapToObj( i -> "a" + i).forEach(System.out::println);
}
Example 16
Project: xbnjava-master  File: ElimDupsFromUnorderedListXmpl.java View source code
public static final void main(String[] ignored) {
    int[] ai = new int[] { 0, 0, 1, 4, 2, 3, 4 };
    ArrayList<Integer> ali = new ArrayList<Integer>(ai.length);
    for (int i : ai) {
        ali.add(i);
    }
    System.out.println(Arrays.toString(ali.toArray()) + "  (original)");
    //Delete dups
    for (int i = 0; i < ali.size(); i++) {
        Integer I = ali.get(i);
        int iA = ali.indexOf(I);
        if (iA != -1) {
            int iB = ali.lastIndexOf(I);
            if (iB != iA) {
                //remove second
                ali.remove(iB);
                System.out.println(Arrays.toString(ali.toArray()));
            }
        }
    }
    System.out.println(Arrays.toString(ali.toArray()) + "     (final)");
}
Example 17
Project: GlowstonePlusPlus-master  File: BlockPotato.java View source code
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
    if (block.getData() >= CropState.RIPE.ordinal()) {
        if (random.nextInt(100) < 2) {
            return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.POTATO_ITEM, random.nextInt(4) + 1), new ItemStack(Material.POISONOUS_POTATO, 1)));
        } else {
            return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.POTATO_ITEM, random.nextInt(4) + 1)));
        }
    } else {
        return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.POTATO_ITEM, 1)));
    }
}
Example 18
Project: checkstyle-master  File: InputMethodReferences.java View source code
public void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);
    numbers.forEach(String.CASE_INSENSITIVE_ORDER::equals);
    InputMethodReferences tl = new InputMethodReferences();
    String roster = new String();
    Supplier<InputMethodReferences> supplier = InputMethodReferences<String>::new;
    numbers.forEach(this::println);
    numbers.forEach(super::println);
    Supplier<InputMethodReferences2> supplier2 = InputMethodReferences2::new;
    Supplier<InputMethodReferences2> suppl = InputMethodReferences2::<Integer>new;
    Function<Integer, String[]> messageArrayFactory = String[]::new;
}
Example 19
Project: abmash-master  File: CheckablePredicate.java View source code
@Override
public void buildCommands() {
    List<String> inputSelectors = Arrays.asList("input[type=checkbox]", "input[type=radio]");
    if (text != null) {
        // close to label
        closeTo(JQueryFactory.select("'" + StringUtils.join(inputSelectors, ',') + "'", 100), new DirectionOptions(DirectionType.CLOSETOCLICKABLELABEL).setLimitPerTarget(1).setMaxDistance(300), QueryFactory.text(text));
        containsText("'" + StringUtils.join(inputSelectors, ',') + "'", text);
        containsAttribute("'" + StringUtils.join(inputSelectors, ',') + "'", "*", text);
    } else {
        add(JQueryFactory.select("'" + StringUtils.join(inputSelectors, ',') + "'", 50));
    }
}
Example 20
Project: ilarkesto-master  File: GwtServiceInterfaceGenerator.java View source code
@Override
protected void printCode(JavaPrinter out) {
    out.package_(getPackageName());
    out.beginInterface(module.getValue() + "Service", Arrays.asList(com.google.gwt.user.client.rpc.RemoteService.class.getName()));
    List<Node> calls = module.getChildrenByTypeRecursive(ServiceCall);
    for (Node call : calls) {
        List<String> params = getParameterTypesAndNames(call, "String");
        params.add(0, "int conversationNumber");
        out.interfaceMethod(getPackageName() + ".DataTransferObject", Str.lowercaseFirstLetter(call.getValue()), params);
    }
    out.endInterface();
}
Example 21
Project: usercenter-master  File: RoleAnnotationHandler.java View source code
public void assertAuthorized(Annotation a) throws AuthorizationException {
    if (!(a instanceof RequiresRoles))
        return;
    RequiresRoles rrAnnotation = (RequiresRoles) a;
    String[] roles = rrAnnotation.value();
    if (roles.length == 1) {
        getSubject().checkRole(roles[0]);
        return;
    }
    if (Logical.AND.equals(rrAnnotation.logical())) {
        getSubject().checkRoles(Arrays.asList(roles));
        return;
    }
    if (Logical.OR.equals(rrAnnotation.logical())) {
        boolean hasAtLeastOneRole = false;
        for (String role : roles) if (getSubject().hasRole(role))
            hasAtLeastOneRole = true;
        if (!hasAtLeastOneRole)
            getSubject().checkRole(roles[0]);
    }
}
Example 22
Project: sitebricks-master  File: HtmlValidatingAcceptanceTest.java View source code
public void shouldGetValidationViolations() {
    WebDriver driver = AcceptanceTest.createWebDriver();
    HtmlValidatingPage page = HtmlValidatingPage.open(driver);
    List<String> expectedValidationViolations = Arrays.asList("Constraint Violation Length First Name Message", "Constraint Violation Null Age Message", "Constraint Violation Length Last Name Message");
    List<String> actualValidationViolations = page.getValidationViolations();
    assert CollectionUtils.isEqualCollection(expectedValidationViolations, actualValidationViolations) : "validation violations didn't match what was expected";
}
Example 23
Project: many-ql-master  File: TestNegation.java View source code
@Parameters
public static Collection<Object[]> data() {
    return Arrays.asList(new Object[][] { // Integer.
    { "-5", true }, // Float.
    { "-10.5", true }, // Strings. Not allowed.
    { "-\"String 1\"", false }, // Booleans. Not allowed.
    { "-true", false }, // Identifiers pointing to a integer.
    { "form myForm { " + "	newQuestion : integer { \"Number\" }" + "	if(-newQuestion * 5 == 5) {}" + "}", true }, // Identifiers pointing to a float.
    { "form myForm { " + "	newQuestion : float { \"Number\" }" + "	if(-newQuestion * 5 == 5) {}" + "}", true }, { "form myForm { " + "	newQuestion : money { \"Number\" }" + "	if(-newQuestion * 5 == 5) {}" + "}", true } });
}
Example 24
Project: violetumleditor-master  File: MenuUtils.java View source code
public static void alterMenuBar(JMenuBar menuBar) {
    MenuElement[] subMenuElements = menuBar.getSubElements();
    List<MenuElement> menuEntryStack = new ArrayList<MenuElement>();
    if (subMenuElements.length > 0) {
        menuEntryStack.addAll(Arrays.asList(subMenuElements));
    }
    while (!menuEntryStack.isEmpty()) {
        MenuElement menuElement = menuEntryStack.get(0);
        if (menuElement instanceof JMenuItem) {
            final JMenuItem menuItem = (JMenuItem) menuElement;
            menuItem.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    System.out.println(menuItem.getName());
                }
            });
        }
        MenuElement[] subElements = menuElement.getSubElements();
        if (subElements.length > 0) {
            menuEntryStack.addAll(Arrays.asList(subElements));
        }
        menuEntryStack.remove(0);
    }
}
Example 25
Project: quickml-master  File: PenalizedMSEScorerTest.java View source code
@Test
public void simpleTest() {
    ClassificationCounter a = new ClassificationCounter();
    a.addClassification("a", 4);
    a.addClassification("b", 9);
    a.addClassification("c", 1);
    ClassificationCounter b = new ClassificationCounter();
    b.addClassification("a", 5);
    b.addClassification("b", 9);
    b.addClassification("c", 6);
    PenalizedMSEScorer mseScorer = new PenalizedMSEScorer(0, 0.0, new AttributeStats<>(Arrays.asList(a, b), a.add(b), "a"));
    Assert.assertTrue(Math.abs(mseScorer.scoreSplit(a, b) - 0.021776929) < 0.000000001);
}