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

/**
 * Selects the optimal picture size with flags to toggle filtering criteria.
 *
 * @param previewSizes       the list of supported preview sizes.
 * @param pictureSizes       the list of supported picture sizes.
 * @param targetWidth        the target picture width.
 * @param targetHeight       the target picture height.
 * @param filterMinSize      true to block sizes smaller than target dimensions; false otherwise.
 * @param filterAspectRatio  true to block sizes above the aspect ratio tolerance; false otherwise.
 * @param filterPreviewSizes true to block sizes without a corresponding preview size; false otherwise.
 * @return the optimal supported picture size; or null if failed.
 *///from ww  w.  j  a  va 2  s . c  o m
private static Size selectPictureSize(List<Size> previewSizes, List<Size> pictureSizes, final int targetWidth,
        final int targetHeight, boolean filterMinSize, boolean filterAspectRatio, boolean filterPreviewSizes) {
    Size optimalSize = null;

    double targetAspectRatio = (double) targetWidth / targetHeight;
    int minArea = Integer.MAX_VALUE;
    for (Size size : pictureSizes) {
        // Block sizes smaller than target dimensions.
        if (filterMinSize && (size.width < targetWidth || size.height < targetHeight)) {
            continue;
        }

        // Block sizes above the aspect ratio tolerance.
        double aspectRatio = (double) size.width / size.height;
        if (filterAspectRatio && (Math.abs(aspectRatio - targetAspectRatio) > PICTURE_ASPECT_RATIO_TOLERANCE)) {
            continue;
        }

        // Block sizes without a corresponding preview size.
        if (filterPreviewSizes && !previewSizes.contains(size)) {
            continue;
        }

        // Select smallest size.
        int area = size.width * size.height;
        if (area < minArea) {
            optimalSize = size;
            minArea = area;
        }
    }

    return optimalSize;
}

From source file:org.craftercms.cstudio.publishing.processor.AbstractPublishingProcessor.java

public AbstractPublishingProcessor() {
    order = Integer.MAX_VALUE;
}

From source file:com.hypersocket.ui.RedirectHandler.java

public RedirectHandler() {
    super("redirect", Integer.MAX_VALUE);
}

From source file:Main.java

public static String readFile(InputStream inputStream, String charset) {
    return readFile(inputStream, charset, Integer.MAX_VALUE);
}

From source file:com.intridea.io.vfs.provider.s3.DepthFileSelector.java

/**
 * Create a file selector that will select ALL files.
 */
public DepthFileSelector() {
    this(0, Integer.MAX_VALUE);
}

From source file:net.bither.model.Depth.java

public static Depth formatJsonOfMarketDepth(MarketType marketType, JSONObject json) throws JSONException {
    Depth depth = new Depth();

    double rate = ExchangeUtil.getRate(marketType);
    int bidMaxPrice = 0;
    int askMinPrice = Integer.MAX_VALUE;

    List<DateValueEntity> bidDateValueEntities = new ArrayList<DateValueEntity>();
    List<DateValueEntity> askDateValueEntities = new ArrayList<DateValueEntity>();
    double bidSumVolume = 0;
    int splitIndex = 0;
    if (!json.isNull(BIDS)) {
        JSONArray bidArray = json.getJSONArray(BIDS);

        for (int i = bidArray.length() - 1; i >= 0; i--) {
            JSONArray bid = bidArray.getJSONArray(i);
            int bidPrice = bid.getInt(0);
            double price = ((double) bidPrice) / 100 * rate;
            double volume = bid.getDouble(1) / Math.pow(10, 8);
            if (bidMaxPrice < bidPrice) {
                bidMaxPrice = bidPrice;/*from  w w w.  j a va2s .  c om*/
            }
            bidSumVolume = bidSumVolume + volume;
            DateValueEntity dateValueEntity = new DateValueEntity((float) bidSumVolume,
                    StringUtil.formatDoubleToMoneyString(price), bidPrice);
            bidDateValueEntities.add(dateValueEntity);

        }
        splitIndex = bidArray.length();

    }
    double askSumVolume = 0;
    if (!json.isNull(ASKS)) {
        JSONArray askArray = json.getJSONArray(ASKS);

        for (int i = 0; i < askArray.length(); i++) {
            JSONArray ask = askArray.getJSONArray(i);
            int askPrice = ask.getInt(0);
            double price = ((double) askPrice) / 100 * rate;
            double volume = ask.getDouble(1) / Math.pow(10, 8);
            askSumVolume = askSumVolume + volume;
            if (askPrice < askMinPrice) {
                askMinPrice = askPrice;
            }
            DateValueEntity dateValueEntity = new DateValueEntity((float) askSumVolume,
                    StringUtil.formatDoubleToMoneyString(price), askPrice);
            askDateValueEntities.add(dateValueEntity);
        }

    }
    int mixPrice = (askMinPrice + bidMaxPrice) / 2;
    DateValueEntity zeroDateValue = new DateValueEntity(0,
            StringUtil.formatDoubleToMoneyString(((double) mixPrice) / 100 * rate), mixPrice);
    List<DateValueEntity> dateValueEntities = new ArrayList<DateValueEntity>();
    dateValueEntities.addAll(bidDateValueEntities);
    dateValueEntities.add(zeroDateValue);
    dateValueEntities.addAll(askDateValueEntities);
    Collections.sort(dateValueEntities, new ComparatorDateValue());
    depth.setMaxVolume(Math.max(askSumVolume, bidSumVolume));
    depth.setDateValueEntities(dateValueEntities);
    depth.setSplitIndex(splitIndex);
    return depth;

}

From source file:NumberUtils.java

/**
 * Convert the given number into an instance of the given target class.
 *
 * @param number      the number to convert
 * @param targetClass the target class to convert to
 * @return the converted number/*from ww  w. j  av a 2  s . c o m*/
 * @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 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 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 number.intValue();
    } else if (targetClass.equals(Long.class)) {
        return number.longValue();
    } else if (targetClass.equals(Float.class)) {
        return number.floatValue();
    } else if (targetClass.equals(Double.class)) {
        return 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:io.github.retz.protocol.data.Range.java

@JsonCreator
public Range(@JsonProperty(value = "min", required = true) int min, @JsonProperty("max") int max) {
    this.min = min;
    if (max == 0) {
        this.max = Integer.MAX_VALUE;
    } else if (max < min) {
        throw new IllegalArgumentException();
    } else {/*from  w  ww .j  a va2s .co m*/
        this.max = max;
    }
}

From source file:etomica.math.SpecialFunctions.java

public static double lnFactorial(int n) {
    if (n < 0) {
        throw new IllegalArgumentException("Argument less than zero: " + n);
    }//from   w w  w . ja  v  a2 s.  c  om
    if (n < 2) {
        return 0;
    }
    long p = 1;
    double sum = 0;
    for (int i = n; i > 1; i--) {
        p *= i;
        if (p > Integer.MAX_VALUE / (p - 1)) {
            sum += Math.log(p);
            p = 1;
        }
    }
    sum += Math.log(p);
    return sum;
}

From source file:io.kamax.mxisd.spring.CloseableHttpClientFactory.java

@Bean
public CloseableHttpClient getClient() {
    return HttpClients.custom().setUserAgent("mxisd").setMaxConnPerRoute(Integer.MAX_VALUE)
            .setMaxConnTotal(Integer.MAX_VALUE).build();
}