Tabnine Logo
Integer
Code IndexAdd Tabnine to your IDE (free)

How to use
Integer
in
java.lang

Best Java code snippets using java.lang.Integer (Showing top 20 results out of 281,403)

origin: google/guava

private static short parseHextet(String ipPart) {
 // Note: we already verified that this string contains only hex digits.
 int hextet = Integer.parseInt(ipPart, 16);
 if (hextet > 0xffff) {
  throw new NumberFormatException();
 }
 return (short) hextet;
}
origin: google/guava

 @Override
 public String toString() {
  return Integer.toString(value);
 }
}
origin: square/okhttp

private int retryAfter(Response userResponse, int defaultDelay) {
 String header = userResponse.header("Retry-After");
 if (header == null) {
  return defaultDelay;
 }
 // https://tools.ietf.org/html/rfc7231#section-7.1.3
 // currently ignores a HTTP-date, and assumes any non int 0 is a delay
 if (header.matches("\\d+")) {
  return Integer.valueOf(header);
 }
 return Integer.MAX_VALUE;
}
origin: spring-projects/spring-framework

  @Override
  public void setAsText(String text) {
    setValue(new Integer(Integer.parseInt(text) + 1));
  }
});
origin: ReactiveX/RxJava

@Test
public void testSynchronousNext() {
  assertEquals(1, BehaviorProcessor.createDefault(1).take(1).blockingSingle().intValue());
  assertEquals(2, BehaviorProcessor.createDefault(2).blockingIterable().iterator().next().intValue());
  assertEquals(3, BehaviorProcessor.createDefault(3).blockingNext().iterator().next().intValue());
}
origin: google/guava

 @Override
 public WeakReference<Object> call() {
  WeakReference<Object> wr =
    new FinalizableWeakReference<Object>(new Integer(23), frq) {
     @Override
     public void finalizeReferent() {
      finalized.release();
     }
    };
  return wr;
 }
}
origin: google/guava

public void testCompare() {
 for (int x : VALUES) {
  for (int y : VALUES) {
   // note: spec requires only that the sign is the same
   assertEquals(x + ", " + y, Integer.valueOf(x).compareTo(y), Ints.compare(x, y));
  }
 }
}
origin: ReactiveX/RxJava

@Test
public void hashCodeIsTheInner() {
  Notification<Integer> n1 = Notification.createOnNext(1337);
  assertEquals(Integer.valueOf(1337).hashCode(), n1.hashCode());
  assertEquals(0, Notification.createOnComplete().hashCode());
}
origin: spring-projects/spring-framework

@Test
public void testCustomNumberEditorWithHex() {
  CustomNumberEditor editor = new CustomNumberEditor(Integer.class, false);
  editor.setAsText("0x" + Integer.toHexString(64));
  assertEquals(new Integer(64), editor.getValue());
}
origin: spring-projects/spring-framework

/**
 * Return a hex String form of an object's identity hash code.
 * @param obj the object
 * @return the object's identity code in hex notation
 */
public static String getIdentityHexString(Object obj) {
  return Integer.toHexString(System.identityHashCode(obj));
}
origin: ReactiveX/RxJava

@Test
public void testLastMultiSubscribe() {
  Maybe<Integer> last = Observable.just(1, 2, 3).lastElement();
  assertEquals(3, last.blockingGet().intValue());
  assertEquals(3, last.blockingGet().intValue());
}
origin: google/guava

public void testToStringLenient_oneIntegerField() {
 String toTest =
   MoreObjects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
 assertTrue(toTest, toTest.matches(".*\\{field1\\=42\\}"));
}
origin: spring-projects/spring-framework

/**
 * Build an identification String for the given {@link DataSource},
 * primarily for logging purposes.
 * @param dataSource the {@code DataSource} to introspect
 * @return the identification String
 */
private String identify(DataSource dataSource) {
  return dataSource.getClass().getName() + '@' + Integer.toHexString(dataSource.hashCode());
}
origin: google/guava

private static byte parseOctet(String ipPart) {
 // Note: we already verified that this string contains only hex digits.
 int octet = Integer.parseInt(ipPart);
 // Disallow leading zeroes, because no clear standard exists on
 // whether these should be interpreted as decimal or octal.
 if (octet > 255 || (ipPart.startsWith("0") && ipPart.length() > 1)) {
  throw new NumberFormatException();
 }
 return (byte) octet;
}
origin: google/guava

 @Override
 public Integer apply(String from) {
  return Integer.valueOf(from);
 }
});
origin: ReactiveX/RxJava

  @Override
  public String apply(Integer v) throws Exception {
    return v.toString();
  }
}).test().assertResult("1");
origin: ReactiveX/RxJava

@Test
public void testSynchronousNext() {
  assertEquals(1, BehaviorProcessor.createDefault(1).take(1).blockingSingle().intValue());
  assertEquals(2, BehaviorProcessor.createDefault(2).blockingIterable().iterator().next().intValue());
  assertEquals(3, BehaviorProcessor.createDefault(3).blockingNext().iterator().next().intValue());
}
origin: google/guava

public void testLeastOfIterator_ties() {
 Integer foo = new Integer(Integer.MAX_VALUE - 10);
 Integer bar = new Integer(Integer.MAX_VALUE - 10);
 assertNotSame(foo, bar);
 assertEquals(foo, bar);
 List<Integer> list = Arrays.asList(3, foo, bar, -1);
 List<Integer> result = numberOrdering.leastOf(list.iterator(), list.size());
 assertEquals(ImmutableList.of(-1, 3, foo, bar), result);
}
origin: google/guava

private static @Nullable String convertDottedQuadToHex(String ipString) {
 int lastColon = ipString.lastIndexOf(':');
 String initialPart = ipString.substring(0, lastColon + 1);
 String dottedQuad = ipString.substring(lastColon + 1);
 byte[] quad = textToNumericFormatV4(dottedQuad);
 if (quad == null) {
  return null;
 }
 String penultimate = Integer.toHexString(((quad[0] & 0xff) << 8) | (quad[1] & 0xff));
 String ultimate = Integer.toHexString(((quad[2] & 0xff) << 8) | (quad[3] & 0xff));
 return initialPart + penultimate + ":" + ultimate;
}
origin: square/okhttp

 private static int parsePort(String input, int pos, int limit) {
  try {
   // Canonicalize the port string to skip '\n' etc.
   String portString = canonicalize(input, pos, limit, "", false, false, false, true, null);
   int i = Integer.parseInt(portString);
   if (i > 0 && i <= 65535) return i;
   return -1;
  } catch (NumberFormatException e) {
   return -1; // Invalid port.
  }
 }
}
java.langInteger

Javadoc

The wrapper for the primitive type int.

Implementation note: The "bit twiddling" methods in this class use techniques described in Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002) and Sean Anderson's Bit Twiddling Hacks.

Most used methods

  • parseInt
    Parses the specified string as a signed integer value using the specified radix. The ASCII character
  • toString
    Converts the specified signed integer into a string representation based on the specified radix. The
  • valueOf
    Parses the specified string as a signed integer value using the specified radix.
  • intValue
    Gets the primitive value of this int.
  • <init>
    Constructs a new Integer from the specified string.
  • toHexString
    Returns a string representation of the integer argument as an unsigned integer in base 16.The unsign
  • equals
    Compares this instance with the specified object and indicates if they are equal. In order to be equ
  • compareTo
    Compares this Integer object to another object. If the object is an Integer, this function behaves l
  • hashCode
  • compare
    Compares two int values.
  • longValue
    Returns the value of this Integer as along.
  • decode
    Parses the specified string and returns a Integer instance if the string can be decoded into an inte
  • longValue,
  • decode,
  • numberOfLeadingZeros,
  • getInteger,
  • doubleValue,
  • toBinaryString,
  • byteValue,
  • bitCount,
  • shortValue,
  • highestOneBit

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now