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:org.elasticsearch.client.sniff.HostsSnifferBuilderTests.java

public void testBuild() throws Exception {
    try {/*from  www.j  a v  a 2 s  . co  m*/
        HostsSniffer.builder(null);
        fail("should have failed");
    } catch (NullPointerException e) {
        assertEquals(e.getMessage(), "restClient cannot be null");
    }

    int numNodes = RandomInts.randomIntBetween(getRandom(), 1, 5);
    HttpHost[] hosts = new HttpHost[numNodes];
    for (int i = 0; i < numNodes; i++) {
        hosts[i] = new HttpHost("localhost", 9200 + i);
    }

    try (RestClient client = RestClient.builder(hosts).build()) {
        try {
            HostsSniffer.builder(client).setScheme(null);
            fail("should have failed");
        } catch (NullPointerException e) {
            assertEquals(e.getMessage(), "scheme cannot be null");
        }

        try {
            HostsSniffer.builder(client).setSniffRequestTimeoutMillis(
                    RandomInts.randomIntBetween(getRandom(), Integer.MIN_VALUE, 0));
            fail("should have failed");
        } catch (IllegalArgumentException e) {
            assertEquals(e.getMessage(), "sniffRequestTimeoutMillis must be greater than 0");
        }

        HostsSniffer.Builder builder = HostsSniffer.builder(client);
        if (getRandom().nextBoolean()) {
            builder.setScheme(RandomPicks.randomFrom(getRandom(), HostsSniffer.Scheme.values()));
        }
        if (getRandom().nextBoolean()) {
            builder.setSniffRequestTimeoutMillis(
                    RandomInts.randomIntBetween(getRandom(), 1, Integer.MAX_VALUE));
        }
        assertNotNull(builder.build());
    }
}

From source file:fr.immotronic.ubikit.pems.enocean.impl.item.data.EEPD201xxDataImpl.java

public static EEPD201xxDataImpl constructDataFromRecord(int EEPType, JSONObject lastKnownData) {
    if (lastKnownData == null) {
        return new EEPD201xxDataImpl(EEPType, null, -1, null, Integer.MIN_VALUE, MeasurementUnit.UNKNOWN, null,
                null);//from ww  w. j  a va 2 s  .  c  o  m
    }

    try {
        SwitchState[] switchStates = new SwitchState[2];
        if (lastKnownData.has("switchState")) {
            switchStates[0] = SwitchState.valueOf(lastKnownData.getString("switchState"));
            switchStates[1] = SwitchState.UNKNOWN;
        } else {
            switchStates[0] = SwitchState.valueOf(lastKnownData.getString("switchState_0"));
            switchStates[1] = SwitchState.valueOf(lastKnownData.getString("switchState_1"));
        }

        int dimmerValue = lastKnownData.getInt("dimmerValue");
        int value = lastKnownData.getInt("value");
        MeasurementUnit unit = MeasurementUnit.valueOf(lastKnownData.getString("unit"));

        Date[] switchStateDates = new Date[2];
        if (lastKnownData.has("switchDate")) {
            long switchDate = lastKnownData.optLong("switchDate");
            switchStateDates[0] = (switchDate == 0) ? null : new Date(switchDate);
            switchStateDates[1] = null;
        } else {
            long switchDate = lastKnownData.optLong("switchDate_0");
            switchStateDates[0] = (switchDate == 0) ? null : new Date(switchDate);

            switchDate = lastKnownData.optLong("switchDate_1");
            switchStateDates[1] = (switchDate == 0) ? null : new Date(switchDate);
        }

        long valueDate = lastKnownData.optLong("valueDate");

        Mode mode = null;
        if (lastKnownData.has("mode")) {
            mode = Mode.valueOf(lastKnownData.getString("mode"));
        }

        return new EEPD201xxDataImpl(EEPType, switchStates, dimmerValue, switchStateDates, value, unit,
                (valueDate == 0) ? null : new Date(valueDate), mode);
    } catch (JSONException e) {
        Logger.error(LC.gi(), null,
                "constructDataFromRecord(): An exception while building a sensorData from a JSONObject SHOULD never happen. Check the code !",
                e);
        return new EEPD201xxDataImpl(EEPType, null, -1, null, Integer.MIN_VALUE, MeasurementUnit.UNKNOWN, null,
                null);
    }
}

From source file:io.pivotal.strepsirrhini.chaosloris.web.ChaosResourceAssemblerTest.java

@Test
public void toResource() {
    Application application = new Application(UUID.randomUUID());
    application.setId(-1L);/*from   w  w w  .j  ava2 s.co  m*/

    Schedule schedule = new Schedule("0 0 * * * *", "hourly");
    schedule.setId(-2L);

    Chaos chaos = new Chaos(application, 0.2, schedule);
    chaos.setId(-3L);

    Event event = new Event(chaos, Instant.EPOCH, Collections.emptyList(), Integer.MIN_VALUE);
    event.setId(-4L);

    when(this.eventRepository.findByChaos(chaos)).thenReturn(Collections.singletonList(event));

    ChaosResourceAssembler.ChaosResource resource = this.resourceAssembler.toResource(chaos);

    assertThat(resource.getContent()).isSameAs(chaos);
    assertThat(resource.getLinks()).hasSize(4);
    assertThat(resource.getLink("application")).isNotNull();
    assertThat(resource.getLink("event")).isNotNull();
    assertThat(resource.getLink("schedule")).isNotNull();
}

From source file:de.hpi.fgis.hdrs.Triple.java

static int ensureNonMagic(int multiplicity) {
    if (Integer.MIN_VALUE == multiplicity) {
        LOG.warn("Ensuring non-magic triple multiplicity!");
        return Integer.MIN_VALUE + 1;
    }/*from  w  w  w  .j a v  a 2  s.  c om*/
    return multiplicity;
}

From source file:org.lightadmin.core.util.NumberUtils.java

@SuppressWarnings("unchecked")
public static <T extends Number> T convertNumberToTargetClass(Number number, Class<T> targetClass)
        throws IllegalArgumentException {
    Assert.notNull(number, "Number must not be null");
    Assert.notNull(targetClass, "Target class must not be null");

    if (targetClass.isInstance(number)) {
        return (T) number;
    } else if (targetClass.equals(byte.class)) {
        long value = number.longValue();
        if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }//  w w  w  .  j a va2 s. c  om
        return (T) 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 (T) new Short(number.shortValue());
    } else if (targetClass.equals(int.class)) {
        long value = number.longValue();
        if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
            raiseOverflowException(number, targetClass);
        }
        return (T) new Integer(number.intValue());
    } else if (targetClass.equals(long.class)) {
        return (T) new Long(number.longValue());
    } else if (targetClass.equals(float.class)) {
        return (T) Float.valueOf(number.toString());
    } else if (targetClass.equals(double.class)) {
        return (T) Double.valueOf(number.toString());
    } else {
        return org.springframework.util.NumberUtils.convertNumberToTargetClass(number, targetClass);
    }
}

From source file:SampleDesktop.java

protected void loadBackgroundImage() {
    ImageIcon icon = new ImageIcon("images/matterhorn.gif");
    JLabel l = new JLabel(icon);
    l.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());

    // Place the image in the lowest possible layer so nothing
    // can ever be painted under it.
    desk.add(l, new Integer(Integer.MIN_VALUE));
}

From source file:io.pivotal.strepsirrhini.chaosloris.data.EventRepositoryTest.java

@Test
public void findByChaos() {
    Schedule schedule = new Schedule("test-schedule", "test-name");
    this.scheduleRepository.saveAndFlush(schedule);

    Application application1 = new Application(UUID.randomUUID());
    this.applicationRepository.saveAndFlush(application1);

    Chaos chaos1 = new Chaos(application1, 0.1, schedule);
    this.chaosRepository.saveAndFlush(chaos1);

    Event event1 = new Event(chaos1, Instant.now(), Collections.emptyList(), Integer.MIN_VALUE);
    this.eventRepository.saveAndFlush(event1);

    Application application2 = new Application(UUID.randomUUID());
    this.applicationRepository.saveAndFlush(application2);

    Chaos chaos2 = new Chaos(application2, 0.1, schedule);
    this.chaosRepository.saveAndFlush(chaos2);

    Event event2 = new Event(chaos2, Instant.now(), Collections.emptyList(), Integer.MIN_VALUE);
    this.eventRepository.saveAndFlush(event2);

    List<Event> events = this.eventRepository.findByChaos(chaos1);
    assertThat(events).containsExactly(event1);
}

From source file:py.una.pol.karaku.replication.server.DummyFirstChangeProvider.java

@Override
public Integer getPriority() {

    return Integer.MIN_VALUE;
}

From source file:com.sisrni.managedbean.CategoriaNoticiaMB.java

/** 
 * Metodo para guardar una instancia de 'CategoriaNoticia' en la tabla 
 * correspondiente de la base de datos//  w  ww.j  a  va 2s  . com
 */
public void guardarCategoriaNoticia() {
    String msg = "Categoria de Noticia Almacenada Exitosamente!";
    try {
        categoriaNoticia.setIdCategoria(Integer.MIN_VALUE);
        categoriaNoticiaService.save(categoriaNoticia);
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_INFO, "Guardada!!", msg));

    } catch (Exception e) {
        JsfUtil.addErrorMessage("Error al Guardar Categoria de Noticia!");
        e.printStackTrace();
    }
    cargarCategoriaNoticia();
}

From source file:io.hops.metadata.ndb.dalimpl.yarn.YarnVariablesClusterJ.java

@Override
public YarnVariables findById(int id) throws StorageException {
    LOG.debug("HOP :: ClusterJ YarnVariables.findById - START:" + id);
    HopsSession session = connector.obtainSession();
    YarnVariablesDTO yarnDTO;//  www  .  j a  v  a2  s .c o m
    if (session != null) {
        if (id == Integer.MIN_VALUE) {
            id = idVal;
        }
        yarnDTO = session.find(YarnVariablesDTO.class, id);
        LOG.debug("HOP :: ClusterJ YarnVariables.findById - FINISH:" + id);
        if (yarnDTO != null) {
            return new YarnVariables(yarnDTO.getid(), yarnDTO.getvalue());
        }
    }
    return null;
}