Skip to content

DATACOUCH-675 - Factor out interfaces for common methods. #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,32 @@ public interface ExecutableInsertByIdOperation {

<T> ExecutableInsertById<T> insertById(Class<T> domainType);

interface TerminatingInsertById<T> {
interface TerminatingInsertById<T> extends OneAndAll<T>{

@Override
T one(T object);

@Override
Collection<? extends T> all(Collection<? extends T> objects);

}

interface InsertByIdWithCollection<T> extends TerminatingInsertById<T> {
interface InsertByIdWithCollection<T> extends TerminatingInsertById<T>, InCollection<T> {

TerminatingInsertById<T> inCollection(String collection);
}

interface InsertByIdWithDurability<T> extends InsertByIdWithCollection<T> {
interface InsertByIdWithDurability<T> extends InsertByIdWithCollection<T>, WithDurability<T> {

InsertByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

InsertByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface InsertByIdWithExpiry<T> extends InsertByIdWithDurability<T> {
interface InsertByIdWithExpiry<T> extends InsertByIdWithDurability<T>, WithExpiry<T> {

@Override
InsertByIdWithDurability<T> withExpiry(Duration expiry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ interface TerminatingRemoveById {

}

interface RemoveByIdWithCollection extends TerminatingRemoveById {
interface RemoveByIdWithCollection extends TerminatingRemoveById, InCollection {

TerminatingRemoveById inCollection(String collection);
}

interface RemoveByIdWithDurability extends RemoveByIdWithCollection {
interface RemoveByIdWithDurability extends RemoveByIdWithCollection, WithDurability {

RemoveByIdWithCollection withDurability(DurabilityLevel durabilityLevel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,40 @@
import java.util.Collection;

import com.couchbase.client.core.msg.kv.DurabilityLevel;
import com.couchbase.client.java.kv.IncrementOptions;
import com.couchbase.client.java.kv.PersistTo;
import com.couchbase.client.java.kv.ReplicateTo;

public interface ExecutableReplaceByIdOperation {

<T> ExecutableReplaceById<T> replaceById(Class<T> domainType);

interface TerminatingReplaceById<T> {
interface TerminatingReplaceById<T> extends OneAndAll<T> {

@Override
T one(T object);

@Override
Collection<? extends T> all(Collection<? extends T> objects);

}

interface ReplaceByIdWithCollection<T> extends TerminatingReplaceById<T> {
interface ReplaceByIdWithCollection<T> extends TerminatingReplaceById<T> , InCollection<T> {

TerminatingReplaceById<T> inCollection(String collection);
}

interface ReplaceByIdWithDurability<T> extends ReplaceByIdWithCollection<T> {
interface ReplaceByIdWithDurability<T> extends ReplaceByIdWithCollection<T>, WithDurability<T> {

ReplaceByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

ReplaceByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface ReplaceByIdWithExpiry<T> extends ReplaceByIdWithDurability<T> {
interface ReplaceByIdWithExpiry<T> extends ReplaceByIdWithDurability<T>, WithExpiry<T> {

@Override
ReplaceByIdWithDurability<T> withExpiry(final Duration expiry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,32 @@ public interface ExecutableUpsertByIdOperation {

<T> ExecutableUpsertById<T> upsertById(Class<T> domainType);

interface TerminatingUpsertById<T> {
interface TerminatingUpsertById<T> extends OneAndAll<T>{

@Override
T one(T object);

@Override
Collection<? extends T> all(Collection<? extends T> objects);

}

interface UpsertByIdWithCollection<T> extends TerminatingUpsertById<T> {
interface UpsertByIdWithCollection<T> extends TerminatingUpsertById<T>, InCollection<T> {

TerminatingUpsertById<T> inCollection(String collection);
}

interface UpsertByIdWithDurability<T> extends UpsertByIdWithCollection<T> {
interface UpsertByIdWithDurability<T> extends UpsertByIdWithCollection<T>, WithDurability<T> {

UpsertByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

UpsertByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface UpsertByIdWithExpiry<T> extends UpsertByIdWithDurability<T> {
interface UpsertByIdWithExpiry<T> extends UpsertByIdWithDurability<T>, WithExpiry<T> {

@Override
UpsertByIdWithDurability<T> withExpiry(Duration expiry);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2020 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.couchbase.core;

/**
* A common interface for all of Insert, Replace, Upsert that take collection
*
* @author Michael Reiche
* @param <T> - the entity class
*/
public interface InCollection<T> {
Object inCollection(String collection);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2020 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.couchbase.core;

import java.util.Collection;

/**
* A common interface for all of Insert, Replace, Upsert
*
* @author Michael Reiche
*
* @param <T> - the entity class
*/
public interface OneAndAll<T> {

T one(T object);

Collection<? extends T> all(Collection<? extends T> objects);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2020 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.couchbase.core;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Collection;

/**
* A common interface for all of Insert, Replace, Upsert
*
* @author Michael Reiche
* @param <T> - the entity class
*/

public interface OneAndAllReactive<T> {
Mono<T> one(T object);

Flux<? extends T> all(Collection<? extends T> objects);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ public interface ReactiveInsertByIdOperation {

<T> ReactiveInsertById<T> insertById(Class<T> domainType);

interface TerminatingInsertById<T> {
interface TerminatingInsertById<T> extends OneAndAllReactive<T>{

Mono<T> one(T object);

Flux<? extends T> all(Collection<? extends T> objects);

}

interface InsertByIdWithCollection<T> extends TerminatingInsertById<T> {
interface InsertByIdWithCollection<T> extends TerminatingInsertById<T>, InCollection<T> {

TerminatingInsertById<T> inCollection(String collection);
}

interface InsertByIdWithDurability<T> extends InsertByIdWithCollection<T> {
interface InsertByIdWithDurability<T> extends InsertByIdWithCollection<T>, WithDurability<T> {

InsertByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

InsertByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface InsertByIdWithExpiry<T> extends InsertByIdWithDurability<T> {
interface InsertByIdWithExpiry<T> extends InsertByIdWithDurability<T>, WithExpiry<T>{

InsertByIdWithDurability<T> withExpiry(Duration expiry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ interface TerminatingRemoveById {

}

interface RemoveByIdWithCollection extends TerminatingRemoveById {
interface RemoveByIdWithCollection extends TerminatingRemoveById, InCollection {

TerminatingRemoveById inCollection(String collection);
}

interface RemoveByIdWithDurability extends RemoveByIdWithCollection {
interface RemoveByIdWithDurability extends RemoveByIdWithCollection, WithDurability {

RemoveByIdWithCollection withDurability(DurabilityLevel durabilityLevel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ public interface ReactiveReplaceByIdOperation {

<T> ReactiveReplaceById<T> replaceById(Class<T> domainType);

interface TerminatingReplaceById<T> {
interface TerminatingReplaceById<T> extends OneAndAllReactive<T> {

Mono<T> one(T object);

Flux<? extends T> all(Collection<? extends T> objects);

}

interface ReplaceByIdWithCollection<T> extends TerminatingReplaceById<T> {
interface ReplaceByIdWithCollection<T> extends TerminatingReplaceById<T>, InCollection<T> {

TerminatingReplaceById<T> inCollection(String collection);
}

interface ReplaceByIdWithDurability<T> extends ReplaceByIdWithCollection<T> {
interface ReplaceByIdWithDurability<T> extends ReplaceByIdWithCollection<T>, WithDurability<T> {

ReplaceByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

ReplaceByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface ReplaceByIdWithExpiry<T> extends ReplaceByIdWithDurability<T> {
interface ReplaceByIdWithExpiry<T> extends ReplaceByIdWithDurability<T>, WithExpiry<T> {

ReplaceByIdWithDurability<T> withExpiry(final Duration expiry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ public interface ReactiveUpsertByIdOperation {

<T> ReactiveUpsertById<T> upsertById(Class<T> domainType);

interface TerminatingUpsertById<T> {
interface TerminatingUpsertById<T> extends OneAndAllReactive<T>{

Mono<T> one(T object);

Flux<? extends T> all(Collection<? extends T> objects);

}

interface UpsertByIdWithCollection<T> extends TerminatingUpsertById<T> {
interface UpsertByIdWithCollection<T> extends TerminatingUpsertById<T>, InCollection<T> {

TerminatingUpsertById<T> inCollection(String collection);
}

interface UpsertByIdWithDurability<T> extends UpsertByIdWithCollection<T> {
interface UpsertByIdWithDurability<T> extends UpsertByIdWithCollection<T>, WithDurability<T> {

UpsertByIdWithCollection<T> withDurability(DurabilityLevel durabilityLevel);

UpsertByIdWithCollection<T> withDurability(PersistTo persistTo, ReplicateTo replicateTo);

}

interface UpsertByIdWithExpiry<T> extends UpsertByIdWithDurability<T> {
interface UpsertByIdWithExpiry<T> extends UpsertByIdWithDurability<T>, WithExpiry<T> {

UpsertByIdWithDurability<T> withExpiry(Duration expiry);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2020 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.couchbase.core;

import com.couchbase.client.core.msg.kv.DurabilityLevel;
import com.couchbase.client.java.kv.PersistTo;
import com.couchbase.client.java.kv.ReplicateTo;

/**
* A common interface for all of Insert, Replace, Upsert that take Durability
*
* @author Michael Reiche
* @param <T> - the entity class
*/
public interface WithDurability<T> {
Object withDurability(DurabilityLevel durabilityLevel);

Object withDurability(PersistTo persistTo, ReplicateTo replicateTo);
}
Loading