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.t3.model.LightSource.java

@Override
public int compareTo(LightSource o) {
    if (o != this) {
        Integer nameLong = NumberUtils.toInt(name, Integer.MIN_VALUE);
        Integer onameLong = NumberUtils.toInt(o.name, Integer.MIN_VALUE);
        if (nameLong != Integer.MIN_VALUE && onameLong != Integer.MIN_VALUE)
            return nameLong - onameLong;
        return name.compareTo(o.name);
    }/*from   ww w  .j a  va2s  .  c om*/
    return 0;
}

From source file:coria2015.server.JsonRPCMethods.java

private int convert(Object p, Arguments description, int score, Object args[], int index) {
        Object o;/*from  w  w w . ja v a  2  s  . co  m*/
        if (p instanceof JSONObject)
            // If p is a map, then use the json name of the argument
            o = ((JSONObject) p).get(description.getArgument(index).name());

        else if (p instanceof JSONArray)
            // if it is an array, then map it
            o = ((JSONArray) p).get(index);
        else {
            // otherwise, suppose it is a one value array
            if (index > 0)
                return Integer.MIN_VALUE;
            o = p;
        }

        final Class aType = description.getType(index);

        if (o == null) {
            if (description.getArgument(index).required())
                return Integer.MIN_VALUE;

            return score - 10;
        }

        if (aType.isArray()) {
            if (o instanceof JSONArray) {
                final JSONArray array = (JSONArray) o;
                final Object[] arrayObjects = args != null ? new Object[array.size()] : null;
                Arguments arguments = new Arguments() {
                    @Override
                    public RPCArgument getArgument(int i) {
                        return new RPCArrayArgument();
                    }

                    @Override
                    public Class<?> getType(int i) {
                        return aType.getComponentType();
                    }

                    @Override
                    public int size() {
                        return array.size();
                    }
                };
                for (int i = 0; i < array.size() && score > Integer.MIN_VALUE; i++) {
                    score = convert(array.get(i), arguments, score, arrayObjects, i);
                }
                return score;
            }
            return Integer.MIN_VALUE;
        }

        if (aType.isAssignableFrom(o.getClass())) {
            if (args != null)
                args[index] = o;
            return score;
        }

        if (o.getClass() == Long.class && aType == Integer.class) {
            if (args != null)
                args[index] = ((Long) o).intValue();
            return score - 1;
        }

        return Integer.MIN_VALUE;
    }

From source file:by.creepid.docsreporter.context.DocContextProcessorTest.java

/**
 * Test of put method, of class DocContextProcessor.
 *//*  w ww.  j  a v  a  2  s  .  c o m*/
@Test
public void testPut() throws IOException {
    System.out.println("******* put ********");

    String string = "project";
    final Object obj = project;

    ImageConverter imageConverter = mock(ImageConverter.class);

    when(imageConverter.isImage(any(byte[].class))).thenReturn(Boolean.TRUE);
    when(imageConverter.isSupportedImageType(any(byte[].class))).thenReturn(Boolean.TRUE);

    when(imageConverter.isImage(null)).thenReturn(Boolean.FALSE);
    when(imageConverter.isSupportedImageType(null)).thenReturn(Boolean.FALSE);

    when(imageConverter.convertPhotoToPreview(logo, 200, Integer.MIN_VALUE)).thenReturn(logoPreview);
    when(imageConverter.convertPhotoToPreview(photo1, 100, Integer.MIN_VALUE)).thenReturn(photo1Preview);
    when(imageConverter.convertPhotoToPreview(photo2, 100, Integer.MIN_VALUE)).thenReturn(photo2Preview);
    when(imageConverter.convertPhotoToPreview(photo3, 100, Integer.MIN_VALUE)).thenReturn(photo3Preview);

    ReflectionTestUtils.invokeSetterMethod(instance, "setImageConverter", imageConverter);

    List<DocTypesFormatter> formatters = new ArrayList<>();

    DocTypesFormatter docDateFormatter = mock(DocTypesFormatter.class);
    when(docDateFormatter.getFromClass()).thenReturn(Date.class);
    when(docDateFormatter.getToClass()).thenReturn(String.class);
    when(docDateFormatter.format(anyObject())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            Date date = (Date) invocation.getArguments()[0];
            return dateFormat.format(date);
        }
    });

    DocTypesFormatter docDecimalFormatter = mock(DocTypesFormatter.class);
    when(docDecimalFormatter.getFromClass()).thenReturn(BigDecimal.class);
    when(docDecimalFormatter.getToClass()).thenReturn(String.class);
    when(docDecimalFormatter.format(anyObject())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            BigDecimal decimal = (BigDecimal) invocation.getArguments()[0];
            return (decimal != null) ? decimalFormatter.format(decimal) : null;
        }
    });

    formatters.add(docDateFormatter);
    formatters.add(docDecimalFormatter);

    ReflectionTestUtils.invokeSetterMethod(instance, "setFormatters", formatters);

    IContext context = mock(IContext.class);

    when(context.put(anyString(), anyObject())).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object arg0 = invocation.getArguments()[0];
            Object arg1 = invocation.getArguments()[1];

            assertNotNull(arg0);

            if (arg1 instanceof ByteArrayImageProvider) {
                ByteArrayImageProvider prov = (ByteArrayImageProvider) arg1;

                assertTrue(prov.isValid());
                assertNotNull(prov.getImageByteArray());
                assertTrue(prov.getImageByteArray().length != 0);
            }

            if (arg0 instanceof String) {
                String str = (String) arg0;

                if (str.equals("project.Date")) {
                    String strDate = (String) arg1;
                    try {
                        dateFormat.parse(strDate);
                    } catch (ParseException ex) {
                        ex.printStackTrace();
                        fail("Cannot parse " + str + " value: " + strDate);
                    }
                }

                if (str.equals("project.Price")) {
                    String strDecimal = (String) arg1;
                    try {
                        decimalFormatter.parse(strDecimal);
                    } catch (ParseException ex) {
                        ex.printStackTrace();
                        fail("Cannot parse " + str + " value: " + strDecimal);
                    }
                }

            }

            return obj;
        }
    });

    instance.setContext(context);
    instance.put(string, obj);
}

From source file:com.taobao.datax.plugins.reader.mysqlreader.MysqlReader.java

private Properties createProperties() {
    Properties p = new Properties();

    String encodeDetail = "";

    if (!StringUtils.isBlank(this.encode)) {
        encodeDetail = "useUnicode=true&characterEncoding=" + this.encode + "&";
    }/*from   w ww .ja v a  2 s. co m*/
    String url = "jdbc:mysql://" + this.ip + ":" + this.port + "/" + this.dbname + "?" + encodeDetail
            + "yearIsDateType=false&zeroDateTimeBehavior=convertToNull" + "&defaultFetchSize="
            + String.valueOf(Integer.MIN_VALUE);

    if (!StringUtils.isBlank(this.mysqlParams)) {
        url = url + "&" + this.mysqlParams;
    }

    p.setProperty("driverClassName", "com.mysql.jdbc.Driver");
    p.setProperty("url", url);
    p.setProperty("username", username);
    p.setProperty("password", password);
    p.setProperty("maxActive", String.valueOf(concurrency + 2));
    p.setProperty("initialSize", String.valueOf(concurrency + 2));
    p.setProperty("maxIdle", "1");
    p.setProperty("maxWait", "1000");
    p.setProperty("defaultReadOnly", "true");
    p.setProperty("testOnBorrow", "true");
    p.setProperty("validationQuery", "select 1 from dual");

    this.logger.info(String.format("MysqlReader try connection: %s .", url));
    return p;
}

From source file:edu.stanford.muse.graph.directed.Digraph.java

public int getLargestComponentSize() {
    Map<Integer, Integer> map = componentSizeScatterPlot();
    int maxSize = Integer.MIN_VALUE;
    for (Integer size : map.keySet())
        if (maxSize < size)
            maxSize = size;//from  w w  w .  ja  v a2 s  . c  o m
    return maxSize;
}

From source file:mesclasses.model.Cours.java

@Override
public int compareTo(Cours t) {
    String cmp = (getStartHour() * 60 + getStartMin()) + classe.getName();
    String cmpt = (t.getStartHour() * 60 + t.getStartMin()) + t.getClasse().getName();
    return classe.getName() == null ? (t.classe.getName() == null ? 0 : Integer.MIN_VALUE)
            : (t.classe.getName() == null ? Integer.MAX_VALUE : cmp.compareTo(cmpt));
}

From source file:com.taobao.weex.devtools.json.ObjectMapperTest.java

@Test
public void testObjectToPrimitive() throws JSONException {
    ArrayOfPrimitivesContainer container = new ArrayOfPrimitivesContainer();
    ArrayList<Object> primitives = container.primitives;
    primitives.add(Long.MIN_VALUE);
    primitives.add(Long.MAX_VALUE);
    primitives.add(Integer.MIN_VALUE);
    primitives.add(Integer.MAX_VALUE);
    primitives.add(Float.MIN_VALUE);
    primitives.add(Float.MAX_VALUE);
    primitives.add(Double.MIN_VALUE);
    primitives.add(Double.MAX_VALUE);

    String json = mObjectMapper.convertValue(container, JSONObject.class).toString();
    JSONObject obj = new JSONObject(json);
    JSONArray array = obj.getJSONArray("primitives");
    ArrayList<Object> actual = new ArrayList<>();
    for (int i = 0, N = array.length(); i < N; i++) {
        actual.add(array.get(i));/*from   w  ww. java 2 s. co  m*/
    }
    assertEquals(primitives.toString(), actual.toString());
}

From source file:com.netflix.aegisthus.io.sstable.SSTableColumnScanner.java

long deserializeColumns(Subscriber<? super AtomWritable> subscriber, byte[] rowKey, long deletedAt, int count,
        DataInput columns) throws IOException {
    long columnSize = 0;
    int actualColumnCount = 0;
    for (int i = 0; i < count; i++, actualColumnCount++) {
        // serialize columns
        OnDiskAtom atom = serializer.deserializeFromSSTable(columns, ColumnSerializer.Flag.PRESERVE_SIZE,
                Integer.MIN_VALUE, version);
        if (atom == null) {
            // If atom was null that means this was a version that does not have version.hasRowSizeAndColumnCount
            // So we have to add the size for the end of row marker also
            columnSize += 2;//from   w w  w  .  j  a  v  a  2 s  .  c  om
            break;
        }
        columnSize += atom.serializedSizeForSSTable();
        subscriber.onNext(AtomWritable.createWritable(rowKey, deletedAt, atom));
    }

    // This is a row with no columns, we still create a writable because we want to preserve this information
    if (actualColumnCount == 0) {
        subscriber.onNext(AtomWritable.createWritable(rowKey, deletedAt, null));
    }

    return columnSize;
}

From source file:com.taobao.datax.common.util.StrUtils.java

License:asdf

public static int getIntParam(String param, int defaultvalue) {
    return getIntParam(param, defaultvalue, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

From source file:com.kakao.helper.SharedPreferencesCache.java

public synchronized int getInt(final String key) {
    int value = memory.getInt(key, Integer.MIN_VALUE);
    if (value == Integer.MIN_VALUE) {
        try {//from  w  w  w . j  a va 2s  .  co m
            deserializeKey(key);
            value = memory.getInt(key, Integer.MIN_VALUE);
        } catch (JSONException e) {
            Logger.getInstance().w("Error reading cached value for key: '" + key + "' -- " + e);
        }
    }
    return value;
}