Guava

How to use Google Guice with Richfaces 4.3.7

喜夏-厌秋 提交于 2020-01-25 05:28:07
问题 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: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl Caused by: java.lang

How to use Google Guice with Richfaces 4.3.7

天大地大妈咪最大 提交于 2020-01-25 05:28:06
问题 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: java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class org.richfaces.resource.ResourceLibraryFactoryImpl Caused by: java.lang

Guava how to copy all files from one directory to another

只愿长相守 提交于 2020-01-24 18:59:25
问题 I have been experimenting with guava lately and I have not come across a way to copy all of the files from one directory to another. If anyone can point me in the right direction on how to do this that would be great. 回答1: Guava is not providing any fancy file manipulation utilities apart from the rather rudimentary functionality in Files. To copy files from one directories, please use a different library, e.g. commons.io.FileUtils.copyDirectory. 来源: https://stackoverflow.com/questions

Guava how to copy all files from one directory to another

夙愿已清 提交于 2020-01-24 18:59:25
问题 I have been experimenting with guava lately and I have not come across a way to copy all of the files from one directory to another. If anyone can point me in the right direction on how to do this that would be great. 回答1: Guava is not providing any fancy file manipulation utilities apart from the rather rudimentary functionality in Files. To copy files from one directories, please use a different library, e.g. commons.io.FileUtils.copyDirectory. 来源: https://stackoverflow.com/questions

Guava cache listener for insertions

拟墨画扇 提交于 2020-01-24 15:37:05
问题 We'd find it very useful to have an AddListener to complement RemovalListener in Google Guava. Is there a suitable alternative to an AddListener that would complement RemovalListener ? 回答1: You can provide that yourself - just pass your custom listener to your computing Function , and whenever you compute a value, notify the listener. If you are using asMap().put(..) , then you'd have to wrap the whole thing in in your custom classes that delegate to the originals but also invoke the addition

How to use Guava's Multisets.toMultiSet() when collecting a stream?

戏子无情 提交于 2020-01-23 19:47:12
问题 I have list of strings, where each string consists of letters separated by the character ',' (comma). I want to go through the list of strings, split on comma, and calculate how many times each letter occurs, and store the result in a Multiset. Blank strings should be ignored, and the split parts should be trimmed. The multiset should be sorted on key. The below code works, i.e., it produces the desired Multiset. However, I couldn't figure out how to use the proper collector method (Multisets

Guava CacheLoader - invalidate does not immediately invalidate entry if both expireAfterWrite and expireAfterAccess are set

蓝咒 提交于 2020-01-23 17:04:13
问题 So for example: CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterAccess(1, TimeUnit.MINUTES) .expireAfterWrite(1, TimeUnit.MINUTES) .build(new CacheLoader<String, Object>() { @Override public Object load (String key) { return ...; } }); If calling invalidate(key) on the returned instance, a subsequent call to getUnchecked() will ALWAYS use the previous value until at least 1 minute has passed in which cause it will call load(key) again. A call to cleanUp() right after invalidate()

Guava CacheLoader - invalidate does not immediately invalidate entry if both expireAfterWrite and expireAfterAccess are set

浪子不回头ぞ 提交于 2020-01-23 17:02:41
问题 So for example: CacheBuilder.newBuilder() .maximumSize(1000) .expireAfterAccess(1, TimeUnit.MINUTES) .expireAfterWrite(1, TimeUnit.MINUTES) .build(new CacheLoader<String, Object>() { @Override public Object load (String key) { return ...; } }); If calling invalidate(key) on the returned instance, a subsequent call to getUnchecked() will ALWAYS use the previous value until at least 1 minute has passed in which cause it will call load(key) again. A call to cleanUp() right after invalidate()

Java 8 Optional asSet()

99封情书 提交于 2020-01-23 07:52:33
问题 So I have been using Guava's Optional for a while now, and I moving to Java 8 so I wanted to use it's Optional class, but it doesn't have my favorite method from Guava, asSet(). Is there a way to do this with the Java 8 Optional that I am not seeing. I love being able to treat optional as a collection so I can do this: for( final User u : getUserOptional().asSet() ) { return u.isPermitted(getPermissionRequired()); } In some cases avoids the need for an additional variable. IE Optional<User>

Why does relocation with the maven shade plugin not work?

瘦欲@ 提交于 2020-01-22 18:24:08
问题 I am having some trouble running a Hadoop job that includes a newer version of Guava than the one that is included in the Hadoop distribution (CDH 5.2). This is a known problem. I try to solve it by shading the libraries using the Maven shade plugin. Therefore, I added the following lines to my pom.xml : <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade<