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

How to use
valueOf
method
in
java.lang.Integer

Best Java code snippets using java.lang.Integer.valueOf (Showing top 20 results out of 92,817)

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: google/guava

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

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

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

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

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

public void testPutAll() {
 Cache<Integer, Integer> cache = CacheBuilder.newBuilder().build();
 cache.putAll(ImmutableMap.of(10, 20, 30, 50, 60, 90));
 assertEquals(Integer.valueOf(20), cache.getIfPresent(10));
 assertEquals(Integer.valueOf(50), cache.getIfPresent(30));
 assertEquals(Integer.valueOf(90), cache.getIfPresent(60));
 cache.asMap().putAll(ImmutableMap.of(10, 50, 30, 20, 60, 70, 5, 5));
 assertEquals(Integer.valueOf(50), cache.getIfPresent(10));
 assertEquals(Integer.valueOf(20), cache.getIfPresent(30));
 assertEquals(Integer.valueOf(70), cache.getIfPresent(60));
 assertEquals(Integer.valueOf(5), cache.getIfPresent(5));
}
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: google/guava

public void testBiMapEntrySetIteratorRemove() {
 BiMap<Integer, String> map = HashBiMap.create();
 map.put(1, "one");
 Set<Entry<Integer, String>> entries = map.entrySet();
 Iterator<Entry<Integer, String>> iterator = entries.iterator();
 Entry<Integer, String> entry = iterator.next();
 entry.setValue("two"); // changes the iterator's current entry value
 assertEquals("two", map.get(1));
 assertEquals(Integer.valueOf(1), map.inverse().get("two"));
 iterator.remove(); // removes the updated entry
 assertTrue(map.isEmpty());
}
origin: google/guava

public void testAsMapWritesThrough() {
 Set<String> strings = Sets.newLinkedHashSet();
 Collections.addAll(strings, "one", "two", "three");
 Map<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map);
 assertEquals(Integer.valueOf(3), map.remove("two"));
 assertThat(strings).containsExactly("one", "three").inOrder();
}
origin: google/guava

public void testNewBuilder() {
 CacheLoader<Object, Integer> loader = constantLoader(1);
 LoadingCache<String, Integer> cache =
   CacheBuilder.newBuilder().removalListener(countingRemovalListener()).build(loader);
 assertEquals(Integer.valueOf(1), cache.getUnchecked("one"));
 assertEquals(1, cache.size());
}
origin: google/guava

public void testAsMap() {
 Set<String> strings = ImmutableSet.of("one", "two", "three");
 Map<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map);
 assertEquals(Integer.valueOf(5), map.get("three"));
 assertNull(map.get("five"));
 assertThat(map.entrySet())
   .containsExactly(mapEntry("one", 3), mapEntry("two", 3), mapEntry("three", 5))
   .inOrder();
}
origin: google/guava

public void testPutIfAbsent() {
 TestMap map = new TestMap();
 map.put("foo", 1);
 assertEquals(Integer.valueOf(1), map.putIfAbsent("foo", 2));
 assertEquals(Integer.valueOf(1), map.get("foo"));
 assertNull(map.putIfAbsent("bar", 3));
 assertEquals(Integer.valueOf(3), map.get("bar"));
}
origin: google/guava

@GwtIncompatible // NavigableMap
public void testAsMapNavigableWritesThrough() {
 NavigableSet<String> strings = Sets.newTreeSet();
 Collections.addAll(strings, "one", "two", "three");
 NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
 assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map);
 assertEquals(Integer.valueOf(3), map.remove("two"));
 assertThat(strings).containsExactly("one", "three").inOrder();
 assertEquals(mapEntry("three", 5), map.subMap("one", false, "zzz", true).pollLastEntry());
 assertThat(strings).contains("one");
}
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: ReactiveX/RxJava

@Test
public void normal() {
  TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
  assertFalse(rso.isDisposed());
  assertEquals(0, rso.start);
  assertNull(rso.value);
  assertTrue(rso.errors.isEmpty());
  Single.just(1).subscribe(rso);
  assertTrue(rso.isDisposed());
  assertEquals(1, rso.start);
  assertEquals(Integer.valueOf(1), rso.value);
  assertTrue(rso.errors.isEmpty());
}
origin: google/guava

public void testGetLargeRangeMap() {
 ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
 for (int i = 0; i < 100; i++) {
  builder.put(Range.closedOpen(i, i + 1), i);
 }
 ImmutableRangeMap<Integer, Integer> map = builder.build();
 for (int i = 0; i < 100; i++) {
  assertEquals(Integer.valueOf(i), map.get(i));
 }
}
origin: google/guava

 public void testReplaceConditional() {
  TestMap map = new TestMap();
  map.put("foo", 1);
  assertFalse(map.replace("foo", 2, 3));
  assertFalse(map.replace("bar", 1, 2));
  assertEquals(Integer.valueOf(1), map.get("foo"));
  assertFalse(map.containsKey("bar"));
  assertTrue(map.replace("foo", 1, 4));
  assertEquals(Integer.valueOf(4), map.get("foo"));
 }
}
origin: google/guava

@GwtIncompatible // SerializableTester
public void testSerialization() {
 ImmutableBiMap<String, Integer> bimap =
   ImmutableBiMap.copyOf(ImmutableMap.of("one", 1, "two", 2));
 ImmutableBiMap<String, Integer> copy = SerializableTester.reserializeAndAssert(bimap);
 assertEquals(Integer.valueOf(1), copy.get("one"));
 assertEquals("one", copy.inverse().get(1));
 assertSame(copy, copy.inverse().inverse());
}
origin: google/guava

public void testRemove() {
 TestMap map = new TestMap();
 map.put("foo", 1);
 assertFalse(map.remove("foo", 2));
 assertFalse(map.remove("bar", 1));
 assertEquals(Integer.valueOf(1), map.get("foo"));
 assertTrue(map.remove("foo", 1));
 assertTrue(map.isEmpty());
}
java.langIntegervalueOf

Javadoc

Returns a Integer instance for the specified integer value.

If it is not necessary to get a new Integer instance, it is recommended to use this method instead of the constructor, since it maintains a cache of instances which may result in better performance.

Popular methods of Integer

  • 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
  • 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
  • numberOfLeadingZeros
    Determines the number of leading zeros in the specified integer prior to the #highestOneBit(int).
  • decode,
  • numberOfLeadingZeros,
  • getInteger,
  • doubleValue,
  • toBinaryString,
  • byteValue,
  • bitCount,
  • shortValue,
  • highestOneBit

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Notification (javax.management)
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top 12 Jupyter Notebook extensions
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