List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:com.projity.algorithm.Merge.java
private void initializeDates() { currentStart = Long.MAX_VALUE; currentEnd = Long.MIN_VALUE; }
From source file:org.apache.bookkeeper.stream.protocol.util.ProtoUtils.java
public static List<RangeProperties> split(long streamId, int numInitialRanges, long nextRangeId, StorageContainerPlacementPolicy placementPolicy) { int numRanges = Math.max(2, numInitialRanges); if (numRanges % 2 != 0) { // round up to odd number numRanges = numRanges + 1;/*from ww w.ja v a 2 s.com*/ } long rangeSize = Long.MAX_VALUE / (numRanges / 2); long startKey = Long.MIN_VALUE; List<RangeProperties> ranges = Lists.newArrayListWithExpectedSize(numRanges); for (int idx = 0; idx < numRanges; ++idx) { long endKey = startKey + rangeSize; if (numRanges - 1 == idx) { endKey = Long.MAX_VALUE; } long rangeId = nextRangeId++; RangeProperties props = RangeProperties.newBuilder().setStartHashKey(startKey).setEndHashKey(endKey) .setStorageContainerId(placementPolicy.placeStreamRange(streamId, rangeId)).setRangeId(rangeId) .build(); startKey = endKey; ranges.add(props); } return ranges; }
From source file:com.basetechnology.s0.agentserver.field.IntField.java
public JSONObject toJson() throws JSONException { JSONObject json = new JSONObject(); json.put("type", "int"); if (symbol.name != null) json.put("name", symbol.name); if (label != null) json.put("label", label); if (description != null) json.put("description", description); if (defaultValue != 0) json.put("default_value", defaultValue); if (minValue != Long.MIN_VALUE) json.put("min_value", minValue); if (maxValue != Long.MAX_VALUE) json.put("max_value", maxValue); if (nominalWidth != 0) json.put("nominal_width", nominalWidth); if (compute != null) json.put("compute", compute); return json;/* ww w. j a v a 2s .c om*/ }
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 www . ja va2s . 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.clustercontrol.maintenance.composite.action.HinemosPropertyDoubleClickListener.java
/** * ?????<BR>/*from w w w . jav a2 s . co m*/ * []????????????? * <P> * <ol> * <li>???????????</li> * <li>?????????</li> * </ol> * * @param event * * @see com.clustercontrol.maintenance.dialog.HinemosPropertyDialog * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) */ @SuppressWarnings("rawtypes") @Override public void doubleClick(DoubleClickEvent event) { ArrayList list; HinemosPropertyInfo info = new HinemosPropertyInfo(); String managerName = null; int valueType = 0; //? if (((StructuredSelection) event.getSelection()).getFirstElement() != null) { list = (ArrayList) ((StructuredSelection) event.getSelection()).getFirstElement(); } else { return; } info.setKey((String) list.get(GetHinemosPropertyTableDefine.KEY)); managerName = (String) list.get(GetHinemosPropertyTableDefine.MANAGER_NAME); valueType = HinemosPropertyTypeMessage .stringToType((String) list.get(GetHinemosPropertyTableDefine.VALUE_TYPE)); info.setValueType(valueType); if (valueType == HinemosPropertyTypeConstant.TYPE_STRING) { String value = (String) list.get(GetHinemosPropertyTableDefine.VALUE); info.setValueString(value); } else if (valueType == HinemosPropertyTypeConstant.TYPE_NUMERIC) { Object val = list.get(GetHinemosPropertyTableDefine.VALUE); try { if (val != null) { info.setValueNumeric(Long.parseLong(val.toString())); } else { info.setValueNumeric(null); } } catch (NumberFormatException e) { m_log.info("run() setValueNumeric(), " + e.getMessage()); Object[] args = { Messages.getString("hinemos.property.key"), Long.MIN_VALUE, Long.MAX_VALUE }; MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.common.4", args)); } } else { boolean value = Boolean.parseBoolean((String) list.get(GetHinemosPropertyTableDefine.VALUE)); info.setValueBoolean(value); } info.setDescription((String) list.get(GetHinemosPropertyTableDefine.DESCRIPTION)); // ? HinemosPropertyDialog dialog = new HinemosPropertyDialog(m_composite.getShell(), managerName, valueType, PropertyDefineConstant.MODE_MODIFY, info); // ??????????? if (dialog.open() == IDialogConstants.OK_ID) { Table table = m_composite.getTableViewer().getTable(); WidgetTestUtil.setTestId(this, null, table); int selectIndex = table.getSelectionIndex(); m_composite.update(); table.setSelection(selectIndex); } }
From source file:cz.maresmar.sfm.view.menu.CursorPagerAdapter.java
/** * Returns first page position (in {@link android.support.v4.view.ViewPager}) that has bigger or * equal ID than selected ID/*from ww w . j a v a2 s . c om*/ * * @param pageId ID of page * @return Position in pager or {@code -1} if not found */ public int getFirstGePosition(long pageId) { if (mCursor == null) throw new IllegalStateException("Not have valid cursor"); long lastPageId = Long.MIN_VALUE; if (mCursor.moveToFirst()) { do { long foundPortalId = mCursor.getLong(mIdColumnIndex); if (BuildConfig.DEBUG) { Assert.that(lastPageId < foundPortalId, "Expected ascending order of IDs, but found !(%d < %d)", lastPageId, foundPortalId); } if (foundPortalId >= pageId) { return mCursor.getPosition(); } lastPageId = foundPortalId; } while (mCursor.moveToNext()); } return -1; }
From source file:emlab.role.market.SubmitLongTermElectricityContractsRole.java
@Transactional public void act(EnergyProducer producer) { // TODO Contracts for checking assigned to power plants?? // When dismantling, take over existing contract by new power plant? for (PowerPlant plant : reps.powerPlantRepository.findOperationalPowerPlantsByOwner(producer, getCurrentTick())) {/*from w ww . j a v a 2 s. c o m*/ // if it is not in the first tick, // and if the plant is within the technical lifetime // and if it is applicable for LTC's (i.e. not wind) // and if there is no contract yet if (getCurrentTick() > 0 && plant.isWithinTechnicalLifetime(getCurrentTick()) && plant.getTechnology().isApplicableForLongTermContract() && reps.contractRepository .findLongTermContractForPowerPlantActiveAtTime(plant, getCurrentTick()) == null) { Zone zone = plant.getLocation().getZone(); double capacity = plant.getAvailableCapacity(getCurrentTick()); double fuelPriceStart = 0d; Substance mainFuel = null; if (!plant.getFuelMix().isEmpty()) { mainFuel = plant.getFuelMix().iterator().next().getSubstance(); fuelPriceStart = findLastKnownPriceForSubstance(mainFuel); } double co2PriceStart = findLastKnownCO2Price(); for (LongTermContractType type : reps.genericRepository.findAll(LongTermContractType.class)) { double hours = 0d; for (Segment s : type.getSegments()) { hours += s.getLengthInHours(); } double averageElectricityPrice = determineAverageElectricityPrice(hours, (int) producer.getLongTermContractPastTimeHorizon(), type); // Count the hours in this contract type. logger.info("LTC type: {}, number of hours: {}", type, hours); logger.info("Weighted average e-price: {}", averageElectricityPrice); double passThroughCO2 = determineCO2Cost(plant) / determineTotalAverageCost(plant, hours); double passThroughFuel = determineFuelCost(plant) / determineTotalAverageCost(plant, hours); long minimumDuration = Long.MAX_VALUE; long maximumDuration = Long.MIN_VALUE; for (LongTermContractDuration duration : reps.genericRepository .findAll(LongTermContractDuration.class)) { if (duration.getDuration() < minimumDuration) { minimumDuration = duration.getDuration(); } if (duration.getDuration() > maximumDuration) { maximumDuration = duration.getDuration(); } } logger.info("Minimum duration: {} and maximum: {}", minimumDuration, maximumDuration); for (LongTermContractDuration duration : reps.genericRepository .findAll(LongTermContractDuration.class)) { double minimumPrice = (1 + producer.getLongTermContractMargin()) * determineTotalAverageCost(plant, hours); double maximumPrice = averageElectricityPrice; // TODO use risk double riskAversionFactor = 1; // Check whether the maximum price is at // least the minimum contract price. Otherwise, // we'll use the minimum price. double thisPrice = 0d; if (maximumPrice < minimumPrice) { thisPrice = minimumPrice; } else { thisPrice = minimumPrice + (((maximumDuration - duration.getDuration()) * (maximumPrice - minimumPrice)) / (maximumDuration - minimumDuration)); } // Skip the first tick for now. Otherwise the // contracts in the LongTermContractOffer offer = reps.contractRepository .submitLongTermContractOfferForElectricity(producer, plant, zone, thisPrice, capacity, type, getCurrentTick(), duration, mainFuel, passThroughFuel, passThroughCO2, fuelPriceStart, co2PriceStart); logger.info("Submitted offer for type {}. The offer: {}", type, offer); } } } } }
From source file:com.netflix.config.DynamicFileConfigurationTest.java
@Test public void testDefaultConfigFile() throws Exception { longProp = propertyFactory.getLongProperty("dprops1", Long.MAX_VALUE, new Runnable() { public void run() { propertyChanged = true;//from ww w . j a v a 2 s.c om } }); DynamicIntProperty validatedProp = new DynamicIntProperty("abc", 0) { @Override public void validate(String newValue) { if (Integer.parseInt(newValue) < 0) { throw new ValidationException("Cannot be negative"); } } }; assertEquals(0, validatedProp.get()); assertFalse(propertyChanged); DynamicDoubleProperty doubleProp = propertyFactory.getDoubleProperty("dprops2", 0.0d); assertEquals(123456789, longProp.get()); assertEquals(123456789, dynProp.getInteger().intValue()); assertEquals(79.98, doubleProp.get(), 0.00001d); assertEquals(Double.valueOf(79.98), doubleProp.getValue()); assertEquals(Long.valueOf(123456789L), longProp.getValue()); modifyConfigFile(); Thread.sleep(1000); assertEquals(Long.MIN_VALUE, longProp.get()); assertEquals(0, validatedProp.get()); assertTrue(propertyChanged); assertEquals(Double.MAX_VALUE, doubleProp.get(), 0.01d); assertFalse(ConfigurationManager.isConfigurationInstalled()); }
From source file:de.decidr.model.facades.TenantFacadeTest.java
@Before public void createDefaultTenant() throws TransactionException { testTenantID = adminFacade.createTenant(TEST_NAME, TEST_DESC, testAdminID); assertNotNull(testTenantID);/* ww w . j a v a 2 s. c o m*/ if (invalidTenantID == null) { long invalidID = Long.MIN_VALUE; for (long l = invalidID; session.createQuery("FROM User WHERE id = :given").setLong("given", l) .uniqueResult() != null; l++) { invalidID = l + 1; } invalidTenantID = invalidID; } assertNotNull(invalidTenantID); }
From source file:de.brands4friends.daleq.integration.tests.FieldTypeTest.java
@Test public void insert_minLong_into_AllTypes() { assertInsertValueInAllFields(Long.MIN_VALUE); }