Questions tagged [guava]

Google's Core Java Library for Java and Android development.

Guava

Guava is an open-source Java library that aims to make working in the Java language more pleasant and more productive.

It contains several core libraries that Google relies on in their Java-based projects: collections, caching, primitives support, concurrency libraries, common annotations, basic string processing, I/O, mathematics, etc.

Resources

3540 questions
2
votes
1 answer

Guava eventbus dispatching error

I'm developing an android application, and I'm using guava eventbus. I get ambiguous errors about not being able to dispatch events. How can I investigate such problems ? and how can I get more information about the exception ? this is a sample…
2
votes
3 answers

Check for empty string null?

I have a json in which userId property is coming as string "null" - "userId":"null" I have a method which checks whether my string is null or not - public static boolean isEmpty(String value) { return value == null || value.isEmpty(); } But…
john
  • 11,311
  • 40
  • 131
  • 251
2
votes
4 answers

Compare two sets of different types

I'm looking for a way to tell if two sets of different element types are identical if I can state one-to-one relation between those element types. Is there a standard way for doing this in java or maybe guava or apache commons? Here is my own…
Vladislav Lezhnin
  • 837
  • 1
  • 7
  • 17
2
votes
1 answer

Subclassing HashBasedTable from guava collection

I have a multilevel map requirement and I am using Guava Table . More precisely HashBasedTable. Since my code needs a lot of custom processing on this dataset I would like to implement a derived class e.g. EventActionRuleTable which holds a map of…
Gautam
  • 1,030
  • 13
  • 37
2
votes
1 answer

Converting Multiset Count into a List Java

Is there any way to pull the count from a Multiset into a list? String[] data = loadStrings("data/data.txt"); Multiset myMultiset = ImmutableMultiset.copyOf(data); for (String word :…
Nebbyyy
  • 358
  • 4
  • 20
2
votes
3 answers

Java data structures: IndexedSet or HashList

Is there a Java data structure that satisfies the following requirements? Indexed access. (i.e., i should be able to retrieve objects with get(i)) Constant time get() & contains() methods Should enforce ordering (enforced by Comparator) Should be…
x-treme
  • 1,606
  • 2
  • 21
  • 39
2
votes
1 answer

Java App Engine call to GcsService.createOrReplace results in Stopwatch.createUnstarted noSuchMethodError after Maven clean/build and deploy

I am using Intellij and Maven for my GAE Java project. I have some strange issues with calling createOrReplace from GcsService in Google Cloud Storage, that is dependent on me editing a single file in my project. Here is what happens: I have a…
clocksmith
  • 6,226
  • 3
  • 32
  • 45
2
votes
3 answers

Java object definition shorthand or shortcuts?

Is there a faster way to instantiate objects in Java where one does not have to retype the class? For example, look at this tome of an instantiation: HashMap> days = new HashMap
Brian Risk
  • 1,244
  • 13
  • 23
2
votes
2 answers

Android project with Guava hitting the limit

I am using Guava in a Android project. I am hitting the 65k method limit which fails the gradle build. I found that this could be resolved by using proguard. I run Proguard on release build and it works fine. I do not want to run proguard on debug…
bond
  • 11,236
  • 7
  • 48
  • 62
2
votes
3 answers

What is the cause of exception when accessing HashMultimap from JSP

I have a Spring MVC controller that adds a Guava HashMultimap to the scope/model. The JSP then reads that data structure to display a list of roles per application : In controller : HashMultimap rolesByApp = HashMultimap.create(); //...…
Pierre Henry
  • 16,658
  • 22
  • 85
  • 105
2
votes
1 answer

Using Guava 19.0, is there a way to map a file extension to a MediaType?

I have a full file path and would like to determine the MediaType (Google's Guava 19.0) it corresponds to. I thought there would be a built in function in MediaType to accomplish this but I don't think so after experimenting and reading the…
2
votes
2 answers

Cache eviction at particular time of the day and not through TTL

Please let me know if cache eviction can be done at particular time of the day instead of TTL. I am using spring framework so if any API provides this feature then I can use this API by plugging into Spring. I did run through search mechanism if…
2
votes
2 answers

How to measure elapsed time with Apache Camel

I need to measure how much time it takes to process external service response in Apache Camel. I've search the web for solutions and surprisingly there was no acceptable one. Using an EventNotifier feels too heavy weight and more framework level…
Paweł Prażak
  • 3,091
  • 1
  • 27
  • 42
2
votes
1 answer

guava bloom filter hight expected false positive percent after insertions

I tries to insert high number of longs to bloom filter and check them with low error. Constructor promise me expected percent for number of insertions, but after all inserts, new expected percent different and very high. BloomFilter
mishka
  • 2,027
  • 2
  • 20
  • 30
2
votes
2 answers

How to validate with ComparisonChain?

I'm using com.google.common.collect.ComparatorChain to implement a custom comparator for different objects. Now, the following tests fails, but why? @Test public void chainTest() { ComparisonChain comparator = ComparisonChain.start() …
membersound
  • 81,582
  • 193
  • 585
  • 1,120
1 2 3
99
100