List of usage examples for java.lang Long valueOf
@HotSpotIntrinsicCandidate public static Long valueOf(long l)
From source file:org.killbill.billing.plugin.meter.timeline.samples.ScalarSample.java
public static ScalarSample fromObject(final Object sampleValue) { if (sampleValue == null) { return new ScalarSample<Void>(SampleOpcode.NULL, null); } else if (sampleValue instanceof Byte) { return new ScalarSample<Byte>(SampleOpcode.BYTE, (Byte) sampleValue); } else if (sampleValue instanceof Short) { return new ScalarSample<Short>(SampleOpcode.SHORT, (Short) sampleValue); } else if (sampleValue instanceof Integer) { try {/* w ww . ja v a 2s . c o m*/ // Can it fit in a short? final short optimizedShort = Shorts.checkedCast(Long.valueOf(sampleValue.toString())); return new ScalarSample<Short>(SampleOpcode.SHORT, optimizedShort); } catch (IllegalArgumentException e) { return new ScalarSample<Integer>(SampleOpcode.INT, (Integer) sampleValue); } } else if (sampleValue instanceof Long) { try { // Can it fit in a short? final short optimizedShort = Shorts.checkedCast(Long.valueOf(sampleValue.toString())); return new ScalarSample<Short>(SampleOpcode.SHORT, optimizedShort); } catch (IllegalArgumentException e) { try { // Can it fit in an int? final int optimizedLong = Ints.checkedCast(Long.valueOf(sampleValue.toString())); return new ScalarSample<Integer>(SampleOpcode.INT, optimizedLong); } catch (IllegalArgumentException ohWell) { return new ScalarSample<Long>(SampleOpcode.LONG, (Long) sampleValue); } } } else if (sampleValue instanceof Float) { return new ScalarSample<Float>(SampleOpcode.FLOAT, (Float) sampleValue); } else if (sampleValue instanceof Double) { return new ScalarSample<Double>(SampleOpcode.DOUBLE, (Double) sampleValue); } else { return new ScalarSample<String>(SampleOpcode.STRING, sampleValue.toString()); } }
From source file:org.lieuofs.district.biz.GestionDistrictTest.java
@Test public void lecture() { IDistrict district = gestionnaire.lire(Long.valueOf(10104l)); assertEquals("N OFS de la Sarine", 1004, district.getNumeroOFS()); assertEquals("Canton de Fribourg", "FR", district.getCanton().getCodeIso2()); }
From source file:de.jfachwert.bank.Kontonummer.java
/** * Eine gueltige Kontonummer beginnt bei 1 und hat maximal 10 Stellen. * * @param kontonr die Kontonummer/*from www .j a v a2 s . c om*/ * @return die validierte Kontonummer zur Weiterverabeitung */ public static String validate(String kontonr) { String normalized = StringUtils.trimToEmpty(kontonr); try { validate(Long.valueOf(normalized)); } catch (NumberFormatException nfe) { throw new InvalidValueException(kontonr, "account_number", nfe); } return normalized; }
From source file:ManagedBeans.FileDownloadViewBean.java
public StreamedContent getFile() { FacesContext currentInstance = FacesContext.getCurrentInstance(); String get = currentInstance.getExternalContext().getRequestParameterMap().get("idFichero"); FicherosScrum find = ficherosScrumFacade.find(Long.valueOf(get)); InputStream input = new ByteArrayInputStream(find.getFichero()); return new DefaultStreamedContent(input, "image/jpg", find.getExt()); }
From source file:me.bramhaag.discordselfbot.commands.util.CommandTimer.java
@Command(name = "timer", minArgs = 1) public void execute(@NonNull Message message, @NonNull TextChannel channel, @NonNull String[] args) { long delay;/*from www . j av a 2 s . c o m*/ try { delay = Long.valueOf(args[0]); } catch (NumberFormatException e) { Util.sendError(message, e.toString()); return; } message.editMessage(new EmbedBuilder().setTitle("Timer", null) .setDescription( "Timer ending in " + DurationFormatUtils.formatDuration(delay * 1000, "H:mm:ss", true)) .setFooter("Timer | " + Util.generateTimestamp(), null).setColor(Color.GREEN).build()).queue(); channel.sendMessage(new EmbedBuilder().setTitle("Timer", null).setDescription("Timer expired!") .setFooter("Timer | " + Util.generateTimestamp(), null).setColor(Color.GREEN).build()) .queueAfter(delay, TimeUnit.SECONDS); }
From source file:org.lieuofs.district.biz.dao.DistrictOFSFichierTxtDaoTest.java
@Test public void lecture() { // District de la Sarine N OFS 1004 PersistDistrict district = dao.lire(Long.valueOf(10104l)); assertEquals("N OFS de la Sarine", 1004, district.getNumero()); }
From source file:$.DocumentQuery.java
public static Document getAuthenticateSuccessOf(InternalOrganization scope, long documentId) { Document result = Document.get(documentId); if (null == result) { return null; }// w ww . j a v a 2s. c om Set<DocumentTag> tags = result.getTags(); for (DocumentTag each : tags) { if (!HOLDER_ORGANIZATION.equals(each.getTagKey())) { continue; } long internalId = Long.valueOf(each.getTagValue()); InternalOrganization internal = InternalOrganizationQuery.create().subordinateOf(scope).id(internalId) .enabled().getSingleResult(); if (null == internal) { return null; } break; } return result; }
From source file:cz.muni.fi.mir.convertors.StringToUserRoleForm.java
@Override public UserRoleForm convert(String source) { if (Tools.getInstance().stringIsEmpty(source)) { return null; } else {// w ww .j a va 2 s .c o m if (source.equals("-1")) { return null; } else { return mapper.map(userRoleService.getUserRoleByID(Long.valueOf(source)), UserRoleForm.class); } } }
From source file:cherry.foundation.crypto.SecureLongEncoderTest.java
@Test public void testEncodeDecode() throws Exception { SecureLongEncoder encoder = createSecureLongEncoder(); for (int i = 0; i < 100; i++) { Long plain = Long.valueOf(random.nextInt()); String crypto = encoder.encode(plain); assertThat(crypto, is(not(plain.toString()))); assertThat(encoder.decode(crypto), is(plain)); }/*w ww . j a v a 2s. c o m*/ }
From source file:com.aurel.track.attachment.BrowseFileBL.java
public static Integer storeImage(Integer workItemID, TPersonBean person, Locale locale, String imageData, boolean addToHistory) { String description = ""; String fileName = "image.jpg"; Integer attachKey = null;//from w ww .ja v a2 s . c o m if (imageData != null) { byte[] bytearray = new Base64().decode(imageData); InputStream is = new ByteArrayInputStream(bytearray); try { TAttachmentBean attachmentBean = AttachBL.save(workItemID, description, fileName, is, person.getObjectID()); attachKey = attachmentBean.getObjectID(); if (addToHistory) { //add to history HistorySaverBL.addAttachment(workItemID, person.getObjectID(), locale, fileName, description, Long.valueOf(bytearray.length), false); } } catch (AttachBLException e) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return attachKey; }