lv.ctco.cukesrest.internal.context.GlobalWorldFacade Maven / Gradle / Ivy
The newest version!
package lv.ctco.cukesrest.internal.context;
import com.google.common.base.*;
import com.google.common.base.Optional;
import com.google.common.collect.*;
import com.google.inject.*;
import java.util.*;
public class GlobalWorldFacade {
@Inject
GlobalWorld world;
@CaptureContext
public void put(@CaptureContext.Pattern String key, @CaptureContext.Value String value) {
world.put(key, value);
}
public Optional get(String key) {
return world.get(key);
}
public String get(String key, String defaultValue) {
Optional value = world.get(key);
return value.isPresent() ? value.get() : defaultValue;
}
public boolean getBoolean(String key) {
return getBoolean(key, false);
}
public boolean getBoolean(String key, boolean defaultValue) {
return Boolean.valueOf(get(key, Boolean.toString(defaultValue)));
}
public void reconstruct() {
world.reconstruct();
}
public Set getKeysStartingWith(final String headerPrefix) {
Set keys = world.keys();
return Sets.filter(keys, new Predicate() {
@Override
public boolean apply(String s) {
return s.startsWith(headerPrefix);
}
});
}
public void remove(String key) {
world.remove(key);
}
public Set keys() {
return world.keys();
}
}