List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:MainClass.java
public static void main(String[] args) { Integer n1 = new Integer(47); Integer n2 = new Integer(47); System.out.println(n1.equals(n2)); }
From source file:Main.java
public static void main(String[] args) { Integer x = new Integer(50); Float y = new Float(50f); System.out.println(x.equals(y)); System.out.println(x.equals(50)); }
From source file:Main.java
public static void main(String[] args) { Integer obj1 = new Integer(5); Integer obj2 = new Integer(5); System.out.println(obj1.equals(obj2)); obj1 = new Integer(3); obj2 = new Integer(2); System.out.println(obj1.equals(obj2)); }
From source file:com.crushpaper.Main.java
public static void main(String[] args) throws IOException { Options options = new Options(); options.addOption("help", false, "print this message"); options.addOption("properties", true, "file system path to the crushpaper properties file"); // Parse the command line. CommandLineParser parser = new BasicParser(); CommandLine commandLine = null;//from w w w .java 2s . c o m try { commandLine = parser.parse(options, args); } catch (ParseException e) { System.err.println("crushpaper: Sorry, could not parse command line because `" + e.getMessage() + "`."); System.exit(1); } if (commandLine == null || commandLine.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("crushpaper", options); return; } // Get the properties path. String properties = null; if (commandLine.hasOption("properties")) { properties = commandLine.getOptionValue("properties"); } if (properties == null || properties.isEmpty()) { System.err.println("crushpaper: Sorry, the `properties` command argument must be specified."); System.exit(1); } Configuration configuration = new Configuration(); if (!configuration.load(new File(properties))) { System.exit(1); } // Get values. File databaseDirectory = configuration.getDatabaseDirectory(); File keyStorePath = configuration.getKeyStoreFile(); Integer httpPort = configuration.getHttpPort(); Integer httpsPort = configuration.getHttpsPort(); Integer httpsProxiedPort = configuration.getHttpsProxiedPort(); String keyStorePassword = configuration.getKeyStorePassword(); String keyManagerPassword = configuration.getKeyManagerPassword(); File temporaryDirectory = configuration.getTemporaryDirectory(); String singleUserName = configuration.getSingleUserName(); Boolean allowSelfSignUp = configuration.getAllowSelfSignUp(); Boolean allowSaveIfNotSignedIn = configuration.getAllowSaveIfNotSignedIn(); File logDirectory = configuration.getLogDirectory(); Boolean loopbackIsAdmin = configuration.getLoopbackIsAdmin(); File sessionStoreDirectory = configuration.getSessionStoreDirectory(); Boolean isOfficialSite = configuration.getIsOfficialSite(); File extraHeaderFile = configuration.getExtraHeaderFile(); // Validate the values. if (httpPort != null && httpsPort != null && httpPort.equals(httpsPort)) { System.err.println("crushpaper: Sorry, `" + configuration.getHttpPortKey() + "` and `" + configuration.getHttpsPortKey() + "` must not be set to the same value."); System.exit(1); } if ((httpsPort == null) != (keyStorePath == null)) { System.err.println("crushpaper: Sorry, `" + configuration.getHttpsPortKey() + "` and `" + configuration.getKeyStoreKey() + "` must either both be set or not set."); System.exit(1); } if (httpsProxiedPort != null && httpsPort == null) { System.err.println("crushpaper: Sorry, `" + configuration.getHttpsProxiedPortKey() + "` can only be set if `" + configuration.getHttpsPortKey() + "` is set."); System.exit(1); } if (databaseDirectory == null) { System.err.println("crushpaper: Sorry, `" + configuration.getDatabaseDirectoryKey() + "` must be set."); System.exit(1); } if (singleUserName != null && !AccountAttributeValidator.isUserNameValid(singleUserName)) { System.err.println( "crushpaper: Sorry, the username in `" + configuration.getSingleUserKey() + "` is not valid."); return; } if (allowSelfSignUp == null || allowSaveIfNotSignedIn == null || loopbackIsAdmin == null) { System.exit(1); } String extraHeader = null; if (extraHeaderFile != null) { extraHeader = readFile(extraHeaderFile); if (extraHeader == null) { System.err.println("crushpaper: Sorry, the file `" + extraHeaderFile.getPath() + "` set in `" + configuration.getExtraHeaderKey() + "` could not be read."); System.exit(1); } } final DbLogic dbLogic = new DbLogic(databaseDirectory); dbLogic.createDb(); final Servlet servlet = new Servlet(dbLogic, singleUserName, allowSelfSignUp, allowSaveIfNotSignedIn, loopbackIsAdmin, httpPort, httpsPort, httpsProxiedPort, keyStorePath, keyStorePassword, keyManagerPassword, temporaryDirectory, logDirectory, sessionStoreDirectory, isOfficialSite, extraHeader); servlet.run(); }
From source file:ArrayUtils.java
/** * A testing method/*from www. j av a2 s .c o m*/ * * @param args * The command-line arguments. The first argument is used to * determine what test to run. */ public static void main(String[] args) { String test; if (args.length == 0) test = "intSort"; else test = args[0]; if (test.equals("intSort")) { int[] random = new int[10000]; int[] random2 = new int[random.length]; for (int i = 0; i < random.length; i++) random[i] = (int) (Math.random() * Integer.MAX_VALUE); ArrayAdjuster.mergeSort(random2, random, 0, random.length); boolean sorted = true; for (int i = 0; i < random.length - 1; i++) if (random[i] < random[i + 1]) { sorted = false; break; } System.out.println("Sort " + (sorted ? "succeeded" : "failed")); } else if (test.equals("adjust")) { final Integer[] start = new Integer[25]; for (int i = 0; i < start.length; i++) start[i] = new Integer(i); Integer[] modifier = new Integer[start.length]; for (int i = 0; i < modifier.length; i++) { if (i % 5 != 0) modifier[i] = new Integer(i); else modifier[i] = new Integer(i / 5 * start.length); } Integer[] result = adjust(start, modifier, new DifferenceListener<Integer, Integer>() { public boolean identity(Integer o1, Integer o2) { return o1.equals(o2); } public Integer added(Integer o, int mIdx, int retIdx) { return o; } public Integer removed(Integer o, int oIdx, int oIdxAdj, int retIdx) { return o; } public Integer set(Integer o1, int idx1, int oIdxAdj, Integer o2, int idx2, int retIdx) { if (o1.intValue() % 5 == 2) return null; return o1; } }); System.out.println("Original array=" + toString(start)); System.out.println("Modifier array=" + toString(modifier)); System.out.println("Adjusted array=" + toString(result)); } else throw new IllegalArgumentException("Unrecognized test: " + test); }
From source file:Main.java
/** * determine if original effort percent is same as the current effort percent for the given detail line * @param detailLine the given effort certification detail line * @return true if original effort percent same as current effort percent *///from www. jav a 2 s. c om public static boolean isOriginalEffortPercentSameAsCurrentEffortPercent(Integer originalEffortPercent, Integer effortPercent) { return originalEffortPercent.equals(effortPercent); }
From source file:amqp.spring.camel.component.SpringAMQPHeader.java
public static Message setBasicPropertiesFromHeaders(Message msg, Map<String, Object> headers) { for (Map.Entry<String, Object> headerEntry : headers.entrySet()) { String headerKey = headerEntry.getKey(); Object headerValue = headerEntry.getValue(); String headerValueString = null; if (headerValue != null) { headerValueString = headerValue.toString(); }// w w w . j a v a 2 s .co m //Not switching on a string since we want to support Java >= 1.6 if (CONTENT_ENCODING.equals(headerKey)) { msg.getMessageProperties().setContentEncoding(headerValueString); } else if (CONTENT_TYPE.equals(headerKey)) { msg.getMessageProperties().setContentType(headerValueString); } else if (CORRELATION_ID.equals(headerKey)) { byte[] correlationId = headerValueString != null ? headerValueString.getBytes() : null; msg.getMessageProperties().setCorrelationId(correlationId); } else if (EXPIRATION.equals(headerKey)) { msg.getMessageProperties().setExpiration(headerValueString); } else if (PRIORITY.equals(headerKey)) { Integer priority = headerValueString != null ? Integer.parseInt(headerValueString) : null; msg.getMessageProperties().setPriority(priority); } else if (REPLY_TO.equals(headerKey)) { msg.getMessageProperties().setReplyTo(headerValueString); } else if (TYPE.equals(headerKey)) { msg.getMessageProperties().setType(headerValueString); } } return msg; }
From source file:com.fengduo.bee.commons.core.lang.Argument.java
/** * 2Integer? <br>/*from ww w. j a va 2s . c o m*/ * * @param num1 * @param num2 * @return */ public static boolean integerEqual(Integer num1, Integer num2) { return num1 == null ? num2 == null : num1.equals(num2); }
From source file:org.waastad.enumjparest.model.Rating.java
@JsonCreator public static Rating create(Integer value) { if (value == null) { throw new IllegalArgumentException(); }//from w ww .j a v a 2 s . co m for (Rating r : values()) { if (value.equals(r.getValue())) { return r; } } throw new IllegalArgumentException(); }
From source file:at.co.federmann.gtd.domain.Status.java
public static Status resolveStatus(Integer id) { if (id == null) { return null; }/*from w w w.j a v a 2 s.co m*/ for (Status status : Status.values()) { if (id.equals(status.id)) { return status; } } throw new IllegalArgumentException(StringUtils.join("No mathing Status found for id ", id)); }