Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Integer MAX_VALUE.

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:Main.java

public static java.awt.event.MouseEvent toAwt(final MouseEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }/*from ww w  .  ja v  a2s  .co  m*/

    final int id;
    if (MouseEvent.MOUSE_MOVED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_MOVED;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_DRAGGED;
    } else if (MouseEvent.MOUSE_CLICKED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_CLICKED;
    } else if (MouseEvent.MOUSE_PRESSED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_PRESSED;
    } else if (MouseEvent.MOUSE_RELEASED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_RELEASED;
    } else if (MouseEvent.MOUSE_ENTERED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_ENTERED;
    } else if (MouseEvent.MOUSE_EXITED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_EXITED;
    } else {
        return null;
    }

    final int button;
    if (event.isPrimaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON1;
    } else if (event.isMiddleButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON2;
    } else if (event.isSecondaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON3;
    } else {
        button = java.awt.event.MouseEvent.NOBUTTON;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int x = (int) event.getX();
    final int y = (int) event.getY();
    final int xAbs = Integer.MAX_VALUE;
    final int yAbs = Integer.MAX_VALUE;
    final int count = event.getClickCount();
    boolean popup = event.isPopupTrigger();
    if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) {
        // mack books use meta flag for right-clicks
        popup = true;
    }
    return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button);
}

From source file:NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 * @param number the number to convert/*from   www .  j  av a 2  s .c  o  m*/
 * @param targetClass the target class to convert to
 * @return the converted number
 * @throws IllegalArgumentException if the target class is not supported
 * (i.e. not a standard Number subclass as included in the JDK)
 * @see java.lang.Byte
 * @see java.lang.Short
 * @see java.lang.Integer
 * @see java.lang.Long
 * @see java.math.BigInteger
 * @see java.lang.Float
 * @see java.lang.Double
 * @see java.math.BigDecimal
 */
public static Number convertNumberToTargetClass(Number number, Class targetClass)
        throws IllegalArgumentException {

    if (targetClass.isInstance(number)) {
        return number;
    } else if (targetClass.equals(Byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Byte(number.byteValue());
    } else if (targetClass.equals(Short.class)) {
        long value = number.longValue();
        if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Short(number.shortValue());
    } else if (targetClass.equals(Integer.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return new Integer(number.intValue());
    } else if (targetClass.equals(Long.class)) {
        return new Long(number.longValue());
    } else if (targetClass.equals(Float.class)) {
        return new Float(number.floatValue());
    } else if (targetClass.equals(Double.class)) {
        return new Double(number.doubleValue());
    } else if (targetClass.equals(BigInteger.class)) {
        return BigInteger.valueOf(number.longValue());
    } else if (targetClass.equals(BigDecimal.class)) {
        // using BigDecimal(String) here, to avoid unpredictability of BigDecimal(double)
        // (see BigDecimal javadoc for details)
        return new BigDecimal(number.toString());
    } else {
        throw new IllegalArgumentException("Could not convert number [" + number + "] of type ["
                + number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
    }
}

From source file:org.codeqinvest.codechanges.scm.factory.CodeChurnCalculatorFactoryTest.java

@Test(expected = UnsupportedScmSystem.class)
public void shouldFailForNotSupportedSvmTypesWithException() {
    ScmConnectionSettings connectionSettings = mock(ScmConnectionSettings.class);
    when(connectionSettings.getType()).thenReturn(Integer.MAX_VALUE);
    codeChurnCalculatorFactory.create(connectionSettings);
}

From source file:de.kitsunealex.projectx.init.ModConfig.java

private static void addProperties(Configuration config) {
    ANIMATION_RESOLUTION = config.get(CATEGORY_CLIENT, "animationResolution", 32,
            "Resoluion of the animation for texture for blocks & items, does not affect the animation if improvedAnimation is enabled",
            16, 128).getInt();/*from  ww w. j  av a  2 s . co m*/
    IMPROVED_ANIMATION = config.get(CATEGORY_CLIENT, "improvedAnimation", true,
            "Offloads the animation rendering to the GPU if OpenGL 4.3 is supported").getBoolean();

    GENERATOR_WEIGHT = config.get(CATEGORY_WORLD, "generatorWeight", 1, "The weight of all world generators", 0,
            Integer.MAX_VALUE).getInt();
    ORE_BLUE_PARAMS = config.get(CATEGORY_WORLD, "xycroniumOreBlue", DEFAULT_ORE_PARAMS,
            "Chance, min height, max height, min vein size, max vein size").getIntList();
    ORE_GREEN_PARAMS = config.get(CATEGORY_WORLD, "xycroniumOreGreen", DEFAULT_ORE_PARAMS,
            "Chance, min height, max height, min vein size, max vein size").getIntList();
    ORE_RED_PARAMS = config.get(CATEGORY_WORLD, "xycroniumOreRed", DEFAULT_ORE_PARAMS,
            "Chance, min height, max height, min vein size, max vein size").getIntList();
    ORE_DARK_PARAMS = config.get(CATEGORY_WORLD, "xycroniumOreDark", DEFAULT_ORE_PARAMS,
            "Chance, min height, max height, min vein size, max vein size").getIntList();
    ORE_LIGHT_PARAMS = config.get(CATEGORY_WORLD, "xycroniumOreLight", DEFAULT_ORE_PARAMS,
            "Chance, min height, max height, min vein size, max vein size").getIntList();

    COMPAT_WAILA = config.get(CATEGORY_COMPAT, "waila", true, "Enable/disable WAILA integration").getBoolean();
    COMPAT_THAUMCRAFT = config.get(CATEGORY_COMPAT, "thaumcraft", true, "Enable/disable Thaumcraft integration")
            .getBoolean();
    COMPAT_FMP = config
            .get(CATEGORY_COMPAT, "forgeMultipart", true, "Enable/disable Forge Multipart integration")
            .getBoolean();
}

From source file:ai.grakn.graql.internal.shell.animalia.chordata.mammalia.artiodactyla.hippopotamidae.HippopotamusFactory.java

public Hippopotamus build() {
    if (size < 5) {
        return new SmallHippopotamusImpl();
    } else if (size < Integer.MAX_VALUE) {
        return new LargeHippopotamusImpl();
    } else {//from   ww w  .j av  a 2 s  .  c  o  m
        return new TitanicHippopotamusImpl();
    }
}

From source file:uk.gov.hscic.common.repo.AbstractRepositoryFactory.java

private R selectRepositoryByPriority() {
    int currentPriority = Integer.MAX_VALUE;
    R selectedRepository = null;//from   w  ww.  j av  a 2  s .com

    for (R repository : repositories.values()) {
        final int priority = repository.getPriority();

        if (priority < currentPriority) {
            currentPriority = priority;
            selectedRepository = repository;
        }
    }

    return selectedRepository;
}

From source file:it.crs4.seal.recab.ArrayListVariantTable.java

public boolean isVariantLocation(String chr, long pos) {
    if (pos > Integer.MAX_VALUE)
        throw new RuntimeException("pos bigger than expected!  File a bug!!");

    ArrayList<Integer> list = data.get(chr);
    if (list != null)
        return Collections.binarySearch(list, (int) pos) >= 0;
    else//from   w  ww .ja  v a  2s. com
        return false;
}

From source file:com.qcadoo.model.internal.types.DecimalTypeTest.java

@Before
public final void init() {
    MockitoAnnotations.initMocks(this);

    decimalType = new DecimalType();
    numberFormat = NumberFormat.getNumberInstance(locale);
    numberFormat.setMaximumFractionDigits(Integer.MAX_VALUE);
    numberFormat.setMaximumIntegerDigits(Integer.MAX_VALUE);
}

From source file:org.biopax.validator.rules.DuplicateIdCaseInsensitiveRule.java

public void check(final Validation validation, Model model) {
    Cluster<BioPAXElement> algorithm = new Cluster<BioPAXElement>() {
        @Override//w w  w.  j  a v  a  2  s . c om
        public boolean match(BioPAXElement a, BioPAXElement b) {
            return !a.equals(b) && a.getUri().equalsIgnoreCase(b.getUri());
        }
    };

    Set<Set<BioPAXElement>> clasters = algorithm.cluster(model.getObjects(), Integer.MAX_VALUE);

    // report the error once for each cluster
    for (Set<BioPAXElement> duplicates : clasters) {
        if (duplicates.size() > 1) {
            BioPAXElement u = duplicates.iterator().next();
            duplicates.remove(u); // keep the first element
            error(validation, u, "duplicate.id.ignoringcase", false, duplicates,
                    u.getModelInterface().getSimpleName());
        }
    }
}

From source file:dataminning2.DBScanGraphplot.java

private int getMax() {
    int max = -Integer.MAX_VALUE;
    for (int i = 0; i < data.length; i++) {
        if (dataY[i] > max)
            max = (int) dataY[i];
    }//from ww w . ja  va  2s.  c o m
    return max;
}