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
0 answers

Equivalent of BeanUtils.getProperty() in Guava

What is Guava's version of BeanUtils.getProperty() implementation? I am bit new Guava library. Could not find anything similar in Guava's reflection library. Need it to write JSR 303 custom validators. final String fieldValue =…
Himanshu Yadav
  • 13,315
  • 46
  • 162
  • 291
2
votes
2 answers

Programming - Java - Disassociate the merge algorithm from the actions

Currently I'm developing a merge between two sorted collections of elements of type T (the type is not important as long you provide a means to compare the Type, for example, in Java, A Comparator will do the work). What I don't want is to…
Victor
  • 3,841
  • 2
  • 37
  • 63
2
votes
1 answer

How to use Google Guice with Richfaces 4.3.7

I'm programming a web app which uses richfaces 4.3.7 and google guice 4.0. The problem is that richfaces using guava 18 und google guice using guava 16, this results with the following Exception: java.lang.RuntimeException:…
user3726033
  • 125
  • 2
  • 10
2
votes
3 answers

Splitting query string using multiple delimiters - java

I would like to split these strings: /d/{?a} /a/b/{c}{?d} /a/b/c{?d} into following list of segments: [d, {?a}] (this case is easy, just split using /) [a, b, {c}, {?d}] [a, b, c, {?d}] For the other cases, splitting using / will not get the…
Budzu
  • 173
  • 2
  • 12
2
votes
2 answers

Why don't cache elements expire promptly?

I have what I thought was a simple use of Guava cache. However, the behavior is not intuitive to me. I have a POJO, Foo with attribute Id (Integer). I use the Integer as the key to the cache when retrieving instances of Foo. If I put three items in…
2
votes
2 answers

Guava Resources.readLines() for Zip/Gzip files

I've found the Resources.readLines() and Files.readLines() to be helpfull in simplifiying my code. The problem is that I often read gzip-compressed txt-files or txt-files in zip archives from URL's (HTTP and FTP). Is there a way to use Guava's…
user1775213
  • 491
  • 1
  • 6
  • 11
2
votes
6 answers

How to delete elements from a transformed collection using a predicate?

If I have an ArrayList dblList and a Predicate IS_EVEN I am able to remove all even elements from dblList using: Collections2.filter(dblList, IS_EVEN).clear() if dblList however is a result of a transformation like dblList =…
Ditz
  • 735
  • 7
  • 17
2
votes
1 answer

Implementing Guava's MurMurHash Properly

I'm a Junior Java Developer and I'm trying to start a small personal project in order to learn the proper ways to do things (in general). I started searching about hash() and while reading an article about the benefits of Guava, I stumbled upon…
Alejandro
  • 766
  • 9
  • 24
2
votes
3 answers

How to subclass Guava's ImmutableList?

When I try to implement my own ImmutableList (actually a wrapper that delegates to the underlying list) I get the following compiler error: ImmutableListWrapper is not abstract and does not override abstract method isPartialView() in…
Gili
  • 86,244
  • 97
  • 390
  • 689
2
votes
2 answers

Register Optional for JDBI

I got a No container builder available for com.google.common.base.Optional error. Here is a fuller stack trace: java.lang.IllegalStateException: No container builder available for com.google.common.base.Optional at …
user4975679
  • 1,461
  • 16
  • 21
2
votes
2 answers

How to create com.google.common.collect.Range with one boud changed?

I need to create new Range object, changing only one (lower or upper) bound. Other bound must be unchanged. What is most convenient way to do that? I see method com.google.common.collect.Range#range(C lower, BoundType lowerType, C upper, BoundType…
Bartosz Bilicki
  • 12,599
  • 13
  • 71
  • 113
2
votes
3 answers

Find if present in enum without iterating?

trying to find an element by its constant parameter/field value(i.e. value0/value1/value2) without iterarting; is there a way? found guava utility method which works for enum constant name(i.e. CONSTANT0/CONSTANT1/CONSTANT2) and not parameter/field…
urmalp
  • 382
  • 2
  • 4
  • 20
2
votes
3 answers

How to wrap a method that returns an optional with fromNullable?

I have a method that I don't own that is returning null but return type is Optional. When I call x.IsPresent() it throws (scenario #2). I tried wrapping the method in a fromNullable but I get a type mismatch (screen shot below). How can…
genxgeek
  • 13,109
  • 38
  • 135
  • 217
2
votes
1 answer

Ensure List of elements ordered by field in element

Using Guava it is possible to ensure ascending ordering this way: import com.google.common.collect.Ordering; import io.predictor.dao.ohlcv.OhlcvHm; import static java.util.stream.Collectors.toList; assertThat("Ordered by age",…
ytterrr
  • 3,036
  • 6
  • 23
  • 32
2
votes
2 answers

How to burst right after creation with Guava rate limiting

We are using guava 16.0.1 On RateLimiter.create(MaxRequestsPerSecond), I cannot burst right away. We would like to allow this as customer rate limiters are only created on their first request and are cached right now(too many customers to hold all…
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212