Examples of IntRange


Examples of com.baulsupp.kolja.log.util.IntRange

   
    int pos = 0;
   
    for (int i = 0; i < height; i++) {
      int newPos = pos + each + (i < leftover ? 1 : 0);
      result.add(new IntRange(pos, newPos));
      pos = newPos;
    }
   
    return result;
  }
View Full Code Here

Examples of de.iritgo.simplelife.math.IntRange

        addressTable.getColumnModel().getColumn(i).setCellRenderer(renderer);
      }

      addressTable.addMouseListener(new AddressTableMouseListener());

      for (int i : new IntRange(0, columns.size() - 1))
      {
        ITableColumn c = columns.get(i);

        if (StringTools.isTrimEmpty(c.getTitle().get()))
        {
View Full Code Here

Examples of groovy.lang.IntRange

        assertEquals("substring(1,3)", object.substring(1, 3), value);
    }

    public void testListGetWithRange() throws Throwable {
        List list = Arrays.asList(new Object[]{"a", "b", "c"});
        Object range = new IntRange(0, 2);
        Object value = invoke(list, "getAt", range);
        assertTrue("Returned List: " + value, value instanceof List);
        List retList = (List) value;
        assertEquals("List size", 3, retList.size());
    }
View Full Code Here

Examples of groovy.lang.IntRange

        // case, we need to reverse them and make sure the range's 'reverse'
        // property is correct.
        // TODO We should probably use DefaultGroovyMethodsSupport.subListBorders(),
        // but that's protected and unavailable to us.
        if (from > to) {
            r = r.isReverse() ? new IntRange(to, from) : new IntRange(from, to);
            from = r.getFromInt();
            to = r.getToInt();
        }

        // Copy the required nodes into a new list.
View Full Code Here

Examples of groovy.lang.IntRange

        assertEquals("substring(1,3)", object.substring(1, 3), value);
    }

    public void testListGetWithRange() throws Throwable {
        List list = Arrays.asList(new Object[]{"a", "b", "c"});
        Object range = new IntRange(0, 2);
        Object value = invoke(list, "getAt", range);
        assertTrue("Returned List: " + value, value instanceof List);
        List retList = (List) value;
        assertEquals("List size", 3, retList.size());
    }
View Full Code Here

Examples of groovy.lang.IntRange

        return RangeConstraint.class;
    }

    public void testValidation() {
        testConstraintMessageCodes(
                getConstraint("testInteger", new IntRange(1, 5)), 7L,
                new String[] {"testClass.testInteger.range.error","testClass.testInteger.range.toobig"},
                new Object[] {"testInteger",TestClass.class, 7L, 1, 5 });

        testConstraintMessageCodes(
                getConstraint("testInteger", new IntRange(1, 5)), 0,
                new String[] {"testClass.testInteger.range.error","testClass.testInteger.range.toosmall"},
                new Object[] {"testInteger",TestClass.class, 0, 1, 5 });

        testConstraintPassed(
                getConstraint("testString", new ObjectRange("abca","abcf")),
                "abcd");

        testConstraintPassed(getConstraint("testInteger", new IntRange(1, 7)), 5);

        // must always pass for null value
        testConstraintPassed(getConstraint("testInteger", new IntRange(1, 7)), null);

        testConstraintDefaultMessage(
                getConstraint("testInteger", new IntRange(1, 5)),
                7,
                "Property [{0}] of class [{1}] with value [{2}] does not fall within the valid range from [{3}] to [{4}]");
    }
View Full Code Here

Examples of groovy.lang.IntRange

                7,
                "Property [{0}] of class [{1}] with value [{2}] does not fall within the valid range from [{3}] to [{4}]");
    }

    public void testCreation() {
        RangeConstraint constraint = (RangeConstraint) getConstraint("testInteger", new IntRange(1,5));
        assertEquals(ConstrainedProperty.RANGE_CONSTRAINT, constraint.getName());
        assertTrue(constraint.supports(Integer.class));
        assertTrue(constraint.supports(Long.class));
        assertTrue(constraint.supports(Double.class));
        assertFalse(constraint.supports(Object.class));
        assertFalse(constraint.supports(null));
        assertEquals(new IntRange(1,5), constraint.getRange());

        try {
            getConstraint("testInteger", "wrong");
            fail("RangeConstraint must throw an exception for non-range parameters.");
        } catch (IllegalArgumentException iae) {
View Full Code Here

Examples of groovy.lang.IntRange

        cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 5);
        assertEquals(5, cp.getMinSize().intValue());

        // validate that getMinSize returns the correct value when the size constraint is defined for the property (but no minSize constraint is defined)
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(10, 20));
        assertEquals(10, cp.getMinSize().intValue());

        // validate that getMinSize returns the maximum of the minSize constraint and the lower bound of the size constraint
        //   1) validate where the lower bound of the size constraint is greater than the minSize constraint
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 6);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(11, 21));
        assertEquals(11, cp.getMinSize().intValue());

        //   2) validate where the minSize constraint is greater than the lower bound of the size constraint
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 12);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(9, 22));
        assertEquals(12, cp.getMinSize().intValue());
    }
View Full Code Here

Examples of groovy.lang.IntRange

        cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 5);
        assertEquals(5, cp.getMaxSize().intValue());

        // validate that getMaxSize returns the correct value when the size constraint is defined for the property (but no maxSize constraint is defined)
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(10, 20));
        assertEquals(20, cp.getMaxSize().intValue());

        // validate that getMaxSize returns the minimum of the maxSize constraint and the upper bound of the size constraint
        //   1) validate where the upper bound of the size constraint is less than the maxSize constraint
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 29);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(11, 21));
        assertEquals(21, cp.getMaxSize().intValue());

        //   2) validate where the maxSize constraint is less than the upper bound of the size constraint
        cp = new ConstrainedProperty(getClass(), "testURL", String.class);
        cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 12);
        cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(9, 22));
        assertEquals(12, cp.getMaxSize().intValue());
    }
View Full Code Here

Examples of groovy.lang.IntRange

    }

    @SuppressWarnings({"unchecked","rawtypes"})
    public void testValidation() {
        testConstraintMessageCodes(
                getConstraint("testString", new IntRange(2, 5)),
                "123456",
                new String[] {"testClass.testString.size.error","testClass.testString.size.toobig"},
                new Object[] {"testString",TestClass.class,"123456", 2, 5 });

        testConstraintMessageCodes(
                getConstraint("testString", new IntRange(2, 5)),
                "1",
                new String[] {"testClass.testString.size.error","testClass.testString.size.toosmall"},
                new Object[] {"testString",TestClass.class,"1", 2, 5 });

        testConstraintPassed(
                getConstraint("testArray", new IntRange(2, 5)),
                new String[] {"one","two","three"});

        List list = new ArrayList();
        list.add("one");
        testConstraintFailed(
                getConstraint("testArray", new IntRange(2, 5)),
                list);

        list.add("two");
        testConstraintPassed(
                getConstraint("testArray", new IntRange(2, 5)),
                list);

        // must always pass on null value
        testConstraintPassed(
                getConstraint("testArray", new IntRange(2, 5)),
                null);

        testConstraintDefaultMessage(
                getConstraint("testString", new IntRange(1, 5)),
                "123456",
                "Property [{0}] of class [{1}] with value [{2}] does not fall within the valid size range from [{3}] to [{4}]");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.