@@ -0,0 +1,2924 @@
+/*%0A *  Copyright (c) 2017 Ot%C3%A1vio Santana and others%0A *   All rights reserved. This program and the accompanying materials%0A *   are made available under the terms of the Eclipse Public License v1.0%0A *   and Apache License v2.0 which accompanies this distribution.%0A *   The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html%0A *   and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.%0A *%0A *   You may elect to redistribute this code under either of these licenses.%0A *%0A *   Contributors:%0A *%0A *   Otavio Santana%0A */%0Apackage org.jnosql.diana.hazelcast.key;%0A%0Aimport com.hazelcast.core.IMap;%0Aimport org.jnosql.diana.api.Value;%0Aimport org.jnosql.diana.api.key.KeyValueEntity;%0A%0Aimport java.time.Duration;%0Aimport java.util.Objects;%0Aimport java.util.Optional;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.function.Function;%0Aimport java.util.stream.Collectors;%0Aimport java.util.stream.StreamSupport;%0A%0A/**%0A * The default implementation of hazelcast bucket manager%0A */%0Aclass DefaultHazelCastBucketManager implements HazelCastBucketManager %7B%0A%0A    private final IMap map;%0A%0A    DefaultHazelCastBucketManager(IMap map) %7B%0A        this.map = map;%0A    %7D%0A%0A    @Override%0A    public %3CK, V%3E void put(K key, V value) %7B%0A        map.put(key, value);%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void put(KeyValueEntity%3CK%3E entity) throws NullPointerException %7B%0A        map.put(entity.getKey(), entity.getValue().get());%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void put(KeyValueEntity%3CK%3E entity, Duration ttl) %7B%0A        map.put(entity.getKey(), entity.getValue().get(), ttl.toMillis(), TimeUnit.MILLISECONDS);%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void put(Iterable%3CKeyValueEntity%3CK%3E%3E entities) throws NullPointerException %7B%0A        StreamSupport.stream(entities.spliterator(), false).forEach(this::put);%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void put(Iterable%3CKeyValueEntity%3CK%3E%3E entities, Duration ttl) throws NullPointerException, UnsupportedOperationException %7B%0A        StreamSupport.stream(entities.spliterator(), false).forEach(kv -%3E this.put(kv, ttl));%0A    %7D%0A%0A    @Override%0A    public %3CK%3E Optional%3CValue%3E get(K key) throws NullPointerException %7B%0A        Object value = map.get(key);%0A        if (value == null) %7B%0A            return Optional.empty();%0A        %7D%0A        return Optional.ofNullable(Value.of(value));%0A    %7D%0A%0A    @Override%0A    public %3CK%3E Iterable%3CValue%3E get(Iterable%3CK%3E keys) throws NullPointerException %7B%0A        return StreamSupport.stream(keys.spliterator(), false).map((Function%3CK, Object%3E) map::get).filter(Objects::nonNull)%0A                .map(Value::of).collect(Collectors.toList());%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void remove(K key) %7B%0A        map.remove(key);%0A    %7D%0A%0A    @Override%0A    public %3CK%3E void remove(Iterable%3CK%3E keys) %7B%0A        StreamSupport.stream(keys.spliterator(), false).forEach(this::remove);%0A    %7D%0A%0A    @Override%0A    public void close() %7B%0A    %7D%0A%7D%0A

create a hazelcast default implementation