Example usage for java.lang Integer MIN_VALUE

List of usage examples for java.lang Integer MIN_VALUE

Introduction

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

Prototype

int MIN_VALUE

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

Click Source Link

Document

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

Usage

From source file:com.vaadin.spring.boot.internal.VaadinServletConfiguration.java

@Bean
public SimpleUrlHandlerMapping vaadinUiForwardingHandlerMapping() {
    SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
    mapping.setOrder(Integer.MIN_VALUE + 1);

    Map<String, Object> urlMappings = new HashMap<String, Object>();

    if (isMappedToRoot()) {

        // map every @SpringUI both with and without trailing slash
        for (String path : getUIPaths()) {
            urlMappings.put("/" + path, vaadinUiForwardingController());
            if (path.length() > 0) {
                urlMappings.put("/" + path + "/", vaadinUiForwardingController());
            }//from w  ww  .ja  va 2  s .co m
        }

        getLogger().info("Forwarding @SpringUI URLs from {}", urlMappings);

    }

    mapping.setUrlMap(urlMappings);

    return mapping;
}

From source file:com.alibaba.wasp.jdbc.command.CommandRemote.java

private void prepareIfRequired() {
    if (session.getLastReconnect() != created) {
        // in this case we need to prepare again in every case
        id = Integer.MIN_VALUE;
    }//from www .j  av a2 s.  c o m
    session.checkClosed();
    if (id <= session.getCurrentId()) {
        // object is too old - we need to prepare again
        prepare(session, false);
    }
}

From source file:com.nridge.core.io.gson.RangeJSON.java

/**
 * Parses an JSON stream and loads it into a field range.
 *
 * @param aReader Json reader stream instance.
 *
 * @throws java.io.IOException I/O related exception.
 *///w  w w  .  ja v a  2  s.co m
public FieldRange load(JsonReader aReader) throws IOException {
    String jsonName;

    boolean isFirst = true;
    Date firstDate = new Date();
    long firstLong = Long.MIN_VALUE;
    int firstInt = Integer.MIN_VALUE;
    double firstDouble = Double.MIN_VALUE;

    Field.Type rangeType = Field.Type.Text;
    FieldRange fieldRange = new FieldRange();

    aReader.beginObject();
    while (aReader.hasNext()) {
        jsonName = aReader.nextName();
        if (StringUtils.equals(jsonName, IO.JSON_TYPE_MEMBER_NAME))
            rangeType = Field.stringToType(aReader.nextString());
        else if (StringUtils.equals(jsonName, IO.JSON_DELIMITER_MEMBER_NAME))
            fieldRange.setDelimiterChar(aReader.nextString());
        else if (StringUtils.equals(jsonName, IO.JSON_VALUE_MEMBER_NAME))
            fieldRange.setItems(StrUtl.expandToList(aReader.nextString(), fieldRange.getDelimiterChar()));
        else if (StringUtils.equals(jsonName, "min")) {
            switch (rangeType) {
            case Long:
                if (isFirst) {
                    isFirst = false;
                    firstLong = aReader.nextLong();
                } else
                    fieldRange = new FieldRange(aReader.nextLong(), firstLong);
                break;
            case Integer:
                if (isFirst) {
                    isFirst = false;
                    firstInt = aReader.nextInt();
                } else
                    fieldRange = new FieldRange(aReader.nextInt(), firstInt);
                break;
            case Double:
                if (isFirst) {
                    isFirst = false;
                    firstDouble = aReader.nextDouble();
                } else
                    fieldRange = new FieldRange(aReader.nextDouble(), firstDouble);
                break;
            case DateTime:
                if (isFirst) {
                    isFirst = false;
                    firstDate = Field.createDate(aReader.nextString());
                } else
                    fieldRange = new FieldRange(Field.createDate(aReader.nextString()), firstDate);
                break;
            default:
                aReader.skipValue();
                break;
            }
        } else if (StringUtils.equals(jsonName, "max")) {
            switch (rangeType) {
            case Long:
                if (isFirst) {
                    isFirst = false;
                    firstLong = aReader.nextLong();
                } else
                    fieldRange = new FieldRange(firstLong, aReader.nextLong());
                break;
            case Integer:
                if (isFirst) {
                    isFirst = false;
                    firstInt = aReader.nextInt();
                } else
                    fieldRange = new FieldRange(firstInt, aReader.nextInt());
                break;
            case Double:
                if (isFirst) {
                    isFirst = false;
                    firstDouble = aReader.nextDouble();
                } else
                    fieldRange = new FieldRange(firstDouble, aReader.nextDouble());
                break;
            case DateTime:
                if (isFirst) {
                    isFirst = false;
                    firstDate = Field.createDate(aReader.nextString());
                } else
                    fieldRange = new FieldRange(firstDate, Field.createDate(aReader.nextString()));
                break;
            default:
                aReader.skipValue();
                break;
            }
        } else
            aReader.skipValue();
    }

    aReader.endObject();

    return fieldRange;
}

From source file:fr.landel.utils.commons.tuple.Generic.java

/**
 * <p>//from   w w  w  .  j  a v a  2 s.c o  m
 * Compares the generic based on the elements in order from left to right.
 * The types must be {@code Comparable}.
 * </p>
 * 
 * @param other
 *            the other generic, not null
 * @return negative if this is less, zero if equal, positive if greater,
 *         {@link Integer#MAX_VALUE} if other is {@code null} or has less
 *         elements and {@link Integer#MIN_VALUE} if other has more elements
 */
@Override
public int compareTo(final Generic<T> other) {
    if (other == null) {
        return Integer.MAX_VALUE;
    } else if (other == this) {
        return 0;
    }

    int length = this.getAll().size();
    int otherLength = other.getAll().size();

    if (length > otherLength) {
        return Integer.MAX_VALUE;
    } else if (length < otherLength) {
        return Integer.MIN_VALUE;
    }

    final CompareToBuilder compareBuilder = new CompareToBuilder();

    final Iterator<T> iterator = this.getAll().iterator();
    final Iterator<T> otherIterator = other.getAll().iterator();
    while (iterator.hasNext() && otherIterator.hasNext()) {
        compareBuilder.append(iterator.next(), otherIterator.next());
    }

    return compareBuilder.toComparison();
}

From source file:com.stratio.ingestion.sink.cassandra.EventParserTest.java

@Test
public void shouldParsePrimitiveTypes() throws Exception {
    Object integer = EventParser.parseValue("1", DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(1);
    integer = EventParser.parseValue(Integer.toString(Integer.MAX_VALUE), DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MAX_VALUE);
    integer = EventParser.parseValue(Integer.toString(Integer.MIN_VALUE), DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(Integer.MIN_VALUE);
    integer = EventParser.parseValue(" 1 2 ", DataType.Name.INT);
    assertThat(integer).isInstanceOf(Integer.class).isEqualTo(12);

    Object counter = EventParser.parseValue("1", DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(1L);//from w ww . j  ava  2s  .c o m
    counter = EventParser.parseValue(Long.toString(Long.MAX_VALUE), DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(Long.MAX_VALUE);
    counter = EventParser.parseValue(Long.toString(Long.MIN_VALUE), DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(Long.MIN_VALUE);
    counter = EventParser.parseValue(" 1 2 ", DataType.Name.COUNTER);
    assertThat(counter).isEqualTo(12L);

    Object _float = EventParser.parseValue("1", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);
    _float = EventParser.parseValue("1.0", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);
    _float = EventParser.parseValue(Float.toString(Float.MAX_VALUE), DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MAX_VALUE);
    _float = EventParser.parseValue(Float.toString(Float.MIN_VALUE), DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(Float.MIN_VALUE);
    _float = EventParser.parseValue(" 1 . 0 ", DataType.Name.FLOAT);
    assertThat(_float).isInstanceOf(Float.class).isEqualTo(1f);

    Object _double = EventParser.parseValue("1", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0);
    _double = EventParser.parseValue("0", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(0.0);
    _double = EventParser.parseValue(Double.toString(Double.MAX_VALUE), DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MAX_VALUE);
    _double = EventParser.parseValue(Double.toString(Double.MIN_VALUE), DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(Double.MIN_VALUE);
    _double = EventParser.parseValue(" 1 . 0 ", DataType.Name.DOUBLE);
    assertThat(_double).isInstanceOf(Double.class).isEqualTo(1.0);

    for (DataType.Name type : Arrays.asList(DataType.Name.BIGINT)) {
        Object bigInteger = EventParser.parseValue("1", type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(1L);
        bigInteger = EventParser.parseValue("0", type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(0L);
        bigInteger = EventParser.parseValue(Long.toString(Long.MAX_VALUE), type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MAX_VALUE);
        bigInteger = EventParser.parseValue(Long.toString(Long.MIN_VALUE), type);
        assertThat(bigInteger).isInstanceOf(Long.class).isEqualTo(Long.MIN_VALUE);
    }

    for (DataType.Name type : Arrays.asList(DataType.Name.VARINT)) {
        Object bigInteger = EventParser.parseValue("1", type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ONE);
        bigInteger = EventParser.parseValue("0", type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class).isEqualTo(BigInteger.ZERO);
        bigInteger = EventParser.parseValue(
                BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class)
                .isEqualTo(BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2L)));
        bigInteger = EventParser.parseValue(
                BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L)).toString(), type);
        assertThat(bigInteger).isInstanceOf(BigInteger.class)
                .isEqualTo(BigInteger.valueOf(Long.MIN_VALUE).multiply(BigInteger.valueOf(2L)));
    }

    Object bigDecimal = EventParser.parseValue("1", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(1));
    bigDecimal = EventParser.parseValue("0", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(0));
    bigDecimal = EventParser.parseValue(
            BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2)).toString(),
            DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class)
            .isEqualTo(BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2)));
    bigDecimal = EventParser.parseValue(
            BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2)).toString(),
            DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class)
            .isEqualTo(BigDecimal.valueOf(Double.MIN_VALUE).multiply(BigDecimal.valueOf(2)));
    bigDecimal = EventParser.parseValue(" 1 2 ", DataType.Name.DECIMAL);
    assertThat(bigDecimal).isInstanceOf(BigDecimal.class).isEqualTo(BigDecimal.valueOf(12));

    Object string = EventParser.parseValue("string", DataType.Name.TEXT);
    assertThat(string).isInstanceOf(String.class).isEqualTo("string");

    Object bool = EventParser.parseValue("true", DataType.Name.BOOLEAN);
    assertThat(bool).isInstanceOf(Boolean.class).isEqualTo(true);

    Object addr = EventParser.parseValue("192.168.1.1", DataType.Name.INET);
    assertThat(addr).isInstanceOf(InetAddress.class).isEqualTo(InetAddress.getByName("192.168.1.1"));

    UUID randomUUID = UUID.randomUUID();
    Object uuid = EventParser.parseValue(randomUUID.toString(), DataType.Name.UUID);
    assertThat(uuid).isInstanceOf(UUID.class).isEqualTo(randomUUID);
}

From source file:com.opengamma.util.timeseries.fast.integer.FastArrayIntDoubleTimeSeries.java

public FastArrayIntDoubleTimeSeries(final DateTimeNumericEncoding encoding, final List<Integer> times,
        final List<Double> values) {
    super(encoding);
    ArgumentChecker.isTrue(times.size() == values.size(), "lists are of different sizes; have {} and {}",
            times.size(), values.size());
    _times = new int[times.size()];
    _values = new double[values.size()];
    final Iterator<Double> iter = values.iterator();
    int i = 0;/*from w  ww.j  av a  2  s  . c o  m*/
    int maxTime = Integer.MIN_VALUE; // for checking the dates are sorted.
    for (final int time : times) {
        final double value = iter.next();
        if (maxTime < time) {
            _times[i] = time;
            _values[i] = value;
            maxTime = time;
        } else {
            throw new IllegalArgumentException("dates must be ordered");
        }
        i++;
    }
}

From source file:com.appsimobile.appsii.module.weather.loader.WeatherDataParser.java

@Nullable
private static WeatherData parseWeatherData(String woeid, SimpleDateFormat simpleDateFormat,
        JSONObject weatherJsonObj) throws ResponseParserException, JSONException, ParseException {
    SimpleJson weatherJson = new SimpleJson(weatherJsonObj);
    String city = weatherJson.optString("location.city");

    if (city == null) {
        String country = weatherJson.optString("location.country");
        String region = weatherJson.optString("location.region");
        if (country != null && region != null) {
            city = TextUtils.join(", ", new String[] { country, region });
        } else if (country != null) {
            city = country;/*from  w ww. jav a  2 s  . c om*/
        }
    }

    if (city == null) {
        Log.w("WeatherDataParser", "Error in weather-query. Ignoring location");
        return null;
    }

    WeatherData weatherData = new WeatherData();

    weatherData.location = city;

    weatherData.windChill = weatherJson.getInt("wind.chill", Integer.MIN_VALUE);
    weatherData.windDirection = weatherJson.getInt("wind.direction", Integer.MIN_VALUE);
    weatherData.windSpeed = (float) weatherJson.getDouble("wind.speed", Float.MIN_VALUE);

    weatherData.atmosphereHumidity = weatherJson.getInt("atmosphere.humidity", Integer.MIN_VALUE);
    weatherData.atmospherePressure = (float) weatherJson.getDouble("atmosphere.pressure", Float.MIN_VALUE);
    weatherData.atmosphereRising = weatherJson.getInt("atmosphere.rising", Integer.MIN_VALUE);
    weatherData.atmosphereVisible = (float) weatherJson.getDouble("atmosphere.visibility", Float.MIN_VALUE);

    weatherData.sunrise = weatherJson.optString("astronomy.sunrise");
    weatherData.sunset = weatherJson.optString("astronomy.sunset");

    weatherData.nowConditionCode = weatherJson.getInt("item.condition.code", WeatherData.INVALID_CONDITION);
    weatherData.nowConditionText = weatherJson.optString("item.condition.text");
    weatherData.nowTemperature = weatherJson.getInt("item.condition.temp", WeatherData.INVALID_TEMPERATURE);

    JSONArray forecastArray = weatherJson.optJsonArray("item.forecast");

    if (forecastArray != null) {

        int fl = forecastArray.length();
        for (int k = 0; k < fl; k++) {
            JSONObject forecastJson = forecastArray.getJSONObject(k);
            WeatherData.Forecast forecast = new WeatherData.Forecast();

            String date = forecastJson.optString("date");
            long millis = simpleDateFormat.parse(date).getTime();

            forecast.julianDay = Time.getJulianDay(millis, 0);
            forecast.conditionCode = forecastJson.optInt("code", WeatherData.INVALID_CONDITION);
            forecast.forecastText = forecastJson.optString("text");
            forecast.low = forecastJson.optInt("low", WeatherData.INVALID_TEMPERATURE);
            forecast.high = forecastJson.optInt("high", WeatherData.INVALID_TEMPERATURE);

            weatherData.forecasts.add(forecast);
        }

    }
    weatherData.woeid = woeid;
    return weatherData;
}

From source file:com.opengamma.util.timeseries.fast.integer.object.FastArrayIntObjectTimeSeries.java

@SuppressWarnings("unchecked")
public FastArrayIntObjectTimeSeries(final DateTimeNumericEncoding encoding, final List<Integer> times,
        final List<T> values) {
    super(encoding);
    if (times.size() != values.size()) {
        throw new IllegalArgumentException("lists are of different sizes");
    }//from   w  w  w  .ja va2  s.  co m
    _times = new int[times.size()];
    _values = (T[]) new Object[values.size()];
    final Iterator<T> iter = values.iterator();
    int i = 0;
    int maxTime = Integer.MIN_VALUE; // for checking the dates are sorted.
    for (final int time : times) {
        final T value = iter.next();
        if (maxTime < time) {
            _times[i] = time;
            _values[i] = value;
            maxTime = time;
        } else {
            throw new IllegalArgumentException("dates must be ordered");
        }
        i++;
    }
}

From source file:org.exoplatform.mongo.factory.MongoFactoryBean.java

private void replSeeds(String... serverAddresses) {
    try {/*w  w  w .  j av  a 2s .c om*/
        replicaSetSeeds.clear();
        for (String addr : serverAddresses) {
            String[] a = addr.split(":");
            String host = a[0].trim();
            if (a.length > 2) {
                throw new IllegalArgumentException("Invalid Server Address : " + addr);
            }
            if (a.length == 2) {
                attemptMongoConnection(host, Integer.parseInt(a[1].trim()));
            } else {
                attemptMongoConnection(host, Integer.MIN_VALUE);
            }
        }
    } catch (Exception e) {
        throw new BeanCreationException("Error while creating replicaSetAddresses", e);
    }
}

From source file:org.opendatakit.ermodel.RelationTest.java

@Test
public void testCase1() throws ODKDatastoreException {

    Date theDate = new Date(DATE_CONSTANT_VALUE);

    MyRelation rel = new MyRelation(callingContext);
    rel = new MyRelation(callingContext);
    Entity e = rel.newEntity(callingContext);
    e.set(MyRelation.fieldStr, "This is a string");
    e.set(MyRelation.fieldDbl, 4.4);/*from  w  w w . j  a  va2 s  .co m*/
    e.set(MyRelation.fieldInt, Integer.MIN_VALUE);
    e.set(MyRelation.fieldDate, theDate);
    e.set(MyRelation.fieldBool, (Boolean) null);
    e.put(callingContext);

    Query query;
    List<Entity> entities;

    query = rel.query("DbTable.testCase1.fieldDbl-lessThan", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.LESS_THAN, 5.0);
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.fieldDbl-lessThanBigDecimal", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.LESS_THAN, new BigDecimal(5.0));
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.fieldDbl-lessThanWrappedBigDecimal", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.LESS_THAN,
            WrappedBigDecimal.fromDouble(5.0));
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.fieldDbl-greaterThan", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.GREATER_THAN, 4.0);
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.fieldDbl-greaterThanBigDecimal", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.GREATER_THAN, new BigDecimal(4.0));
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.fieldDbl-greaterThanWrappedBigDecimal", callingContext);
    query.addFilter(MyRelation.fieldDbl.getName(), FilterOperation.GREATER_THAN,
            WrappedBigDecimal.fromDouble(4.0));
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    query = rel.query("DbTable.testCase1.intMinValue", callingContext);
    query.addFilter(MyRelation.fieldInt.getName(), FilterOperation.EQUAL, Integer.MIN_VALUE);
    entities = query.execute();
    assertEquals(1, entities.size());
    assertEquals(e.getId(), entities.get(0).getId());

    Entity eKey = rel.getEntity(e.getId(), callingContext);
    assertEquals(e.getId(), eKey.getId());
    Date eDate = e.getDate(MyRelation.fieldDate);
    Date eKeyDate = eKey.getDate(MyRelation.fieldDate);
    assertEquals(
            (eDate.getTime() / PersistConsts.MIN_DATETIME_RESOLUTION) * PersistConsts.MIN_DATETIME_RESOLUTION,
            (eKeyDate.getTime() / PersistConsts.MIN_DATETIME_RESOLUTION)
                    * PersistConsts.MIN_DATETIME_RESOLUTION);

    assertNull(eKey.getBoolean(MyRelation.fieldBool));

    eKey.set(MyRelation.fieldInt, 40);
    eKey.set(MyRelation.fieldBool, true);
    MyRelation.putEntity(eKey, callingContext);

    Entity eNew = rel.getEntity(e.getId(), callingContext);
    assertEquals(eNew.getInteger(MyRelation.fieldInt), Integer.valueOf(40));
    assertTrue(eNew.getBoolean(MyRelation.fieldBool));

    e.put(callingContext);
    eKey = rel.getEntity(e.getId(), callingContext);
    assertEquals(eKey.getInteger(MyRelation.fieldInt), Integer.valueOf(Integer.MIN_VALUE));

    rel.dropRelation(callingContext);
}