repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithCreatedDate.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithCreatedDate.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.CreatedDate; import java.util.Date; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithCreatedDate { private String id; @CreatedDate private Date createdDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public Date getCreatedDate() { return createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdFieldAndAnAnnotatedIdField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithIdFieldAndAnAnnotatedIdField.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:54 PM) */ @SuppressWarnings("unused") public class EntityWithIdFieldAndAnAnnotatedIdField { private String id; @Id private String annotatedId; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getAnnotatedId() { return annotatedId; } public void setAnnotatedId(String annotatedId) { this.annotatedId = annotatedId; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithMultipleAnnotatedFields.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithMultipleAnnotatedFields.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:52 PM) */ @SuppressWarnings("unused") public class EntityWithMultipleAnnotatedFields { @Id private String first; @Id private String second; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithLastModifiedBy.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithLastModifiedBy.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.LastModifiedBy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:20 PM) */ @SuppressWarnings("unused") public class EntityWithLastModifiedBy { private String id; @LastModifiedBy private String lastModifiedBy; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getLastModifiedBy() { return lastModifiedBy; } public void setLastModifiedBy(String lastModifiedBy) { this.lastModifiedBy = lastModifiedBy; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/SampleClass.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/SampleClass.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:18 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class SampleClass { //returns void private void getProperty() { } //returns void, has a parameter private void getProperty(int parameter) { } //returns void, has a parameter, does not start with get private void hasProperty() { } //has a parameter @SuppressWarnings("SameReturnValue") private Object getProperty(String parameter) { return null; } //has a parameter, does not start with get @SuppressWarnings("SameReturnValue") private Object hasProperty(String parameter) { return null; } //returns void, does not start with get private void hasState() { } //does not have get as a single word at the beginning @SuppressWarnings("SameReturnValue") private String getterMethod() { return null; } //proper getter @SuppressWarnings("SameReturnValue") private String getValue() { return null; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotationOnIdFieldAndGetter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotationOnIdFieldAndGetter.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:21 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class EntityWithAnnotationOnIdFieldAndGetter { @Id private Object field; @Id private void getProperty() { //this nativeMethod is just a stub for the `property` property getter } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/BaseEntity.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/BaseEntity.java
package com.mmnaseri.utils.spring.data.sample.models; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/26/15) */ @SuppressWarnings("unused") public class BaseEntity { private String id; public BaseEntity() { } public BaseEntity(String id) { this.id = id; } public String getId() { return id; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdFieldFromJPA.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithAnnotatedIdFieldFromJPA.java
package com.mmnaseri.utils.spring.data.sample.models; import javax.persistence.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (6/8/16, 1:18 AM) */ @SuppressWarnings("unused") public class EntityWithAnnotatedIdFieldFromJPA { @Id private Long customIdProperty; public Long getCustomIdProperty() { return customIdProperty; } public void setCustomIdProperty(Long customIdProperty) { this.customIdProperty = customIdProperty; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithMultipleAnnotatedIdGetters.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/models/EntityWithMultipleAnnotatedIdGetters.java
package com.mmnaseri.utils.spring.data.sample.models; import org.springframework.data.annotation.Id; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:53 PM) */ @SuppressWarnings("unused") public class EntityWithMultipleAnnotatedIdGetters { private String first; private String second; @Id public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } @Id public String getSecond() { return second; } public void setSecond(String second) { this.second = second; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithErrorThrowingAccessors.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithErrorThrowingAccessors.java
package com.mmnaseri.utils.spring.data.sample.usecases.tools; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:56 PM) */ @SuppressWarnings("unused") public class ClassWithErrorThrowingAccessors { public String getId() { throw new RuntimeException(); } public void setId(String id) { throw new RuntimeException(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithFinalId.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithFinalId.java
package com.mmnaseri.utils.spring.data.sample.usecases.tools; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:56 PM) */ @SuppressWarnings("unused") public class ClassWithFinalId { private final String id = null; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithNoGetters.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithNoGetters.java
package com.mmnaseri.utils.spring.data.sample.usecases.tools; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:56 PM) */ @SuppressWarnings("unused") public class ClassWithNoGetters { private String id; }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithPrimitiveField.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/tools/ClassWithPrimitiveField.java
package com.mmnaseri.utils.spring.data.sample.usecases.tools; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:57 PM) */ @SuppressWarnings("unused") public class ClassWithPrimitiveField { private int position; public int getPosition() { return position; } public void setPosition(int position) { this.position = position; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/LowerPriorityMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/LowerPriorityMapping.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import org.springframework.core.annotation.Order; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:53 PM) */ @Order(-1) public class LowerPriorityMapping { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ErrorThrowingImplementation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ErrorThrowingImplementation.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:54 PM) */ public class ErrorThrowingImplementation { public ErrorThrowingImplementation() { throw new RuntimeException(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ImplementationWithoutADefaultConstructor.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ImplementationWithoutADefaultConstructor.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:54 PM) */ @SuppressWarnings("unused") public class ImplementationWithoutADefaultConstructor { public ImplementationWithoutADefaultConstructor(String parameter) { } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ImplementationWithPrivateConstructor.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ImplementationWithPrivateConstructor.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:54 PM) */ public class ImplementationWithPrivateConstructor { private ImplementationWithPrivateConstructor() { } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingInvocationHandler.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingInvocationHandler.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 11:15 AM) */ public class InformationExposingInvocationHandler<E> implements InvocationHandler { private final InformationExposingRepository implementation; private final E instance; public InformationExposingInvocationHandler(InformationExposingRepository implementation, E instance) { this.implementation = implementation; this.instance = instance; } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getDeclaringClass().equals(InformationExposingRepository.class)) { return method.invoke(implementation, args); } return method.invoke(instance, args); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ReturnTypeSampleRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ReturnTypeSampleRepository.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.springframework.data.domain.Page; import org.springframework.data.domain.Slice; import org.springframework.data.geo.GeoPage; import org.springframework.util.concurrent.ListenableFuture; import java.math.BigDecimal; import java.util.*; import java.util.concurrent.Future; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:31 PM) */ public interface ReturnTypeSampleRepository { Object findOther(); Set findSet(); CustomCollectionImplementation findCustomCollection(); Future findFuture(); GeoPage findGeoPage(); Iterator findIterator(); Iterable findIterable(); ListenableFuture findListenableFuture(); List findList(); int findPrimitive(); Queue findQueue(); LinkedList findLinkedList(); Slice findSlice(); Page findPage(); int findInt(); long findLong(); short findShort(); double findDouble(); float findFloat(); byte findByte(); BigDecimal findBigDecimal(); Integer findInteger(); void doSomething(); Person findPerson(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ProperImplementation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ProperImplementation.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:54 PM) */ public class ProperImplementation { @SuppressWarnings("SameReturnValue") public Double pi() { return Math.PI; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingRepositoryFactory.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingRepositoryFactory.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactory; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.impl.DefaultRepositoryFactory; import com.mmnaseri.utils.spring.data.proxy.impl.ImmutableRepositoryConfiguration; import java.lang.reflect.Proxy; import java.util.Arrays; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 11:10 AM) */ public class InformationExposingRepositoryFactory implements RepositoryFactory { private final RepositoryFactoryConfiguration configuration; private final RepositoryFactory delegate; public InformationExposingRepositoryFactory(RepositoryFactoryConfiguration configuration) { this.configuration = configuration; delegate = new DefaultRepositoryFactory(configuration); } @Override public <E> E getInstance(KeyGenerator<?> keyGenerator, Class<E> repositoryInterface, Class... implementations) { final E instance = delegate.getInstance(keyGenerator, repositoryInterface, implementations); //noinspection unchecked final RepositoryConfiguration configuration = new ImmutableRepositoryConfiguration( this.configuration.getRepositoryMetadataResolver().resolve(repositoryInterface), keyGenerator, Arrays.asList(implementations)); final DefaultInformationExposingRepository implementation = new DefaultInformationExposingRepository( configuration, getConfiguration()); final InformationExposingInvocationHandler<E> handler = new InformationExposingInvocationHandler<>( implementation, instance); final Object proxyInstance = Proxy.newProxyInstance(instance.getClass().getClassLoader(), new Class[]{ repositoryInterface, InformationExposingRepository.class }, handler); return repositoryInterface.cast(proxyInstance); } @Override public RepositoryFactoryConfiguration getConfiguration() { return configuration; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ErrorThrowingCallable.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/ErrorThrowingCallable.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import java.util.concurrent.Callable; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:55 PM) */ public class ErrorThrowingCallable implements Callable { @Override public Object call() { throw new RuntimeException(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/HighPriorityMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/HighPriorityMapping.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import org.springframework.core.annotation.Order; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:54 PM) */ @Order(1) public class HighPriorityMapping { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/InformationExposingRepository.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 11:12 AM) */ public interface InformationExposingRepository { RepositoryFactoryConfiguration getFactoryConfiguration(); RepositoryConfiguration getConfiguration(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/DefaultInformationExposingRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/DefaultInformationExposingRepository.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 11:13 AM) */ public class DefaultInformationExposingRepository implements InformationExposingRepository { private final RepositoryConfiguration configuration; private final RepositoryFactoryConfiguration factoryConfiguration; public DefaultInformationExposingRepository(RepositoryConfiguration configuration, RepositoryFactoryConfiguration factoryConfiguration) { this.configuration = configuration; this.factoryConfiguration = factoryConfiguration; } @Override public RepositoryFactoryConfiguration getFactoryConfiguration() { return factoryConfiguration; } @Override public RepositoryConfiguration getConfiguration() { return configuration; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/CustomCollectionImplementation.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/CustomCollectionImplementation.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy; import com.mmnaseri.utils.spring.data.proxy.impl.adapters.EmptyIterator; import javax.annotation.Nonnull; import java.util.AbstractCollection; import java.util.Iterator; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:31 PM) */ @SuppressWarnings("unused") class CustomCollectionImplementation extends AbstractCollection { @Override @Nonnull public Iterator iterator() { return EmptyIterator.INSTANCE; } @Override public int size() { return 0; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/converters/NoOpResultConverter.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/converters/NoOpResultConverter.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.converters; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.proxy.impl.converters.AbstractResultConverter; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:26 PM) */ public class NoOpResultConverter extends AbstractResultConverter { private Object original; @Override protected Object doConvert(Invocation invocation, Object original) { this.original = original; return original; } public Object getOriginal() { return original; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperInterface.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperInterface.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:35 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public interface SuperInterface { void saySomething(CharSequence sequence, Double number); void doSomething(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperClass.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperClass.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:36 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class SuperClass { public void saySomething(CharSequence sequence, Number number) { } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SampleMappedRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SampleMappedRepository.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; import org.springframework.data.jpa.repository.Query; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:31 PM) */ public interface SampleMappedRepository { void mappedSignature(String string); void findByFirstName(String firstName); @Query void nativeMethod(); void normalMethodBy(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperInterfaceImpl.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/SuperInterfaceImpl.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:36 PM) */ @SuppressWarnings("unused") public class SuperInterfaceImpl implements SuperInterface { @Override public void saySomething(CharSequence sequence, Double number) { } @Override public void doSomething() { } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/NoOpMethodQueryDescriptionExtractor.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/NoOpMethodQueryDescriptionExtractor.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.domain.impl.MethodQueryDescriptionExtractor; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import java.lang.reflect.Method; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:32 PM) */ public class NoOpMethodQueryDescriptionExtractor extends MethodQueryDescriptionExtractor { private boolean called; public NoOpMethodQueryDescriptionExtractor() { super(null); called = false; } @Override public QueryDescriptor extract(RepositoryMetadata repositoryMetadata, RepositoryFactoryConfiguration configuration, Method method) { called = true; return null; } public boolean isCalled() { return called; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/MappedType.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/MappedType.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:31 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class MappedType { public void mappedSignature(CharSequence value) { } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/ChildClass.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/ChildClass.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:36 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class ChildClass extends SuperClass { public void saySomething(String string, Integer number) { //this nativeMethod's signature will match the name plus parameter types (? extends String, ? extends Integer) //since both of these classes are final, it means that it will only match the exact same nativeMethod } public void doSomething() { //this nativeMethod's signature is empty, so only its name will be considered } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/ProxiedClass.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/proxy/resolvers/ProxiedClass.java
package com.mmnaseri.utils.spring.data.sample.usecases.proxy.resolvers; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:36 PM) */ public interface ProxiedClass { void saySomething(String something, Double number); void saySomething(String something, float number); void saySomething(String something, Integer number); void saySomething(String something, Boolean flag); void doSomething(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/store/SampleAuditorAware.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/store/SampleAuditorAware.java
package com.mmnaseri.utils.spring.data.sample.usecases.store; import org.springframework.data.domain.AuditorAware; import javax.annotation.Nonnull; import java.util.Optional; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 5:19 PM) */ public class SampleAuditorAware implements AuditorAware<String> { public static final String AUDITOR = "AUDITOR"; @Override @Nonnull public Optional<String> getCurrentAuditor() { return Optional.of(AUDITOR); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/domain/MappedClass.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/usecases/domain/MappedClass.java
package com.mmnaseri.utils.spring.data.sample.usecases.domain; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:52 PM) */ @SuppressWarnings({"unused", "EmptyMethod"}) public class MappedClass { private final Object value; public MappedClass(Object value) { this.value = value; } private void privateMethod() { } public void errorThrowingMethod() { throw new RuntimeException(); } public Object validMethod() { return value; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimplePersonSerializableRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimplePersonSerializableRepository.java
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.PersonSerializable; import org.springframework.data.repository.Repository; /** * @author blackleg */ public interface SimplePersonSerializableRepository extends Repository<PersonSerializable, String> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/NumberMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/NumberMapping.java
package com.mmnaseri.utils.spring.data.sample.repositories; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:09 PM) */ @SuppressWarnings("unused") public class NumberMapping { @SuppressWarnings("SameReturnValue") public Integer getNumber() { return 123; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimplePersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimplePersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.springframework.data.repository.Repository; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public interface SimplePersonRepository extends Repository<Person, String> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ConfiguredSimplePersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ConfiguredSimplePersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:09 PM) */ public interface ConfiguredSimplePersonRepository extends SimplePersonRepository { RepositoryConfiguration getRepositoryConfiguration(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ConfiguredMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ConfiguredMapping.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfigurationAware; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:10 PM) */ @SuppressWarnings("unused") public class ConfiguredMapping implements RepositoryConfigurationAware { private RepositoryConfiguration repositoryConfiguration; @Override public void setRepositoryConfiguration(RepositoryConfiguration repositoryConfiguration) { this.repositoryConfiguration = repositoryConfiguration; } public RepositoryConfiguration getRepositoryConfiguration() { return repositoryConfiguration; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/RepositoryWithValidMethods.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/RepositoryWithValidMethods.java
package com.mmnaseri.utils.spring.data.sample.repositories; import org.springframework.data.domain.Pageable; import java.util.Collection; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:08 PM) */ @SuppressWarnings("unused") public interface RepositoryWithValidMethods { void find(); void test(); void findByFirstNameAndLastNameEquals(String firstName, String lastName); void findByFirstNameAndLastNameIgnoreCase(String firstName, String lastName); void findByFirstNameOrderByLastNameDescAgeAsc(String firstName); void findByFirstNameOrLastName(String firstName, String lastName); void findByFirstNameOrderByLastNameDesc(String firstName, Pageable pageable); void findByFirstName(String firstName, Pageable pageable); void findByFirstName(String firstName, org.springframework.data.domain.Sort sort); void findByFirstNameIn(Collection<String> names); void findByFirstNameAndLastNameAllIgnoreCase(String firstName, String lastName); void functionNameByFirstName(String firstName); void findByFirstNameAndLastNameOrAddressCityOrAgeGreaterThan(String firstName, String lastName, String city, Integer age); void findAll(); void findAll(Pageable pageable); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SampleAnnotatedRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SampleAnnotatedRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.springframework.data.repository.RepositoryDefinition; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:04 PM) */ @RepositoryDefinition(domainClass = Person.class, idClass = String.class) public interface SampleAnnotatedRepository { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/StringMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/StringMapping.java
package com.mmnaseri.utils.spring.data.sample.repositories; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:09 PM) */ @SuppressWarnings("unused") public class StringMapping { @SuppressWarnings("SameReturnValue") public String getString() { return "Hello!"; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimpleCrudPersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/SimpleCrudPersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Person; import java.util.List; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:47 PM) */ public interface SimpleCrudPersonRepository extends SimplePersonRepository { Person save(Person person); void delete(Person person); List<Person> findAll(); List<Person> deleteAll(); List<Person> findByLastName(String lastName); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ExtendedSimplePersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ExtendedSimplePersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:09 PM) */ public interface ExtendedSimplePersonRepository extends SimplePersonRepository { String getString(); Number getNumber(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/JpaPersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/JpaPersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.springframework.data.jpa.repository.JpaRepository; /** * @author Balthasar Biedermann * @since 1.1.5 (11/7/18) */ public interface JpaPersonRepository extends JpaRepository<Person, String> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/MalformedRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/MalformedRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:07 PM) */ @SuppressWarnings("unused") public interface MalformedRepository { void Malformed(); void findFirst5First10(); void findFirstFirst10(); void findTop10Top5(); void findDistinctDistinct(); void findTop10Distinct(); void findTop10DistinctBy(); void findByUnknownProperty(); void findByFirstName(); void findByFirstNameAnd(String firstName); void findByFirstNameOr(String firstName); void findByFirstName(Object name); void findByFirstName(String name, Object extra); void findByFirstName(String name, Object first, Object second); void findByFirstNameOrderBy(String firstName); void findByFirstNameOrderByAddressAsc(String firstName); void findByFirstNameOrderByXyzDesc(String firstName); void findByFirstNameOrderByFirstNameAsc(String firstName, org.springframework.data.domain.Sort sort); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/DefaultMethodPersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/DefaultMethodPersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Person; import java.util.List; public interface DefaultMethodPersonRepository extends SimplePersonRepository { List<Person> findByAgeGreaterThan(int age); default List<Person> theInterestingPeople() { return findByAgeGreaterThan(99); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/AnnotatedInheritingRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/AnnotatedInheritingRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.sample.models.Address; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.springframework.data.repository.Repository; import org.springframework.data.repository.RepositoryDefinition; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 7:05 PM) */ @RepositoryDefinition(domainClass = Person.class, idClass = String.class) public interface AnnotatedInheritingRepository extends Repository<Address, String> { }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ClearableSimpleCrudPersonRepository.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/ClearableSimpleCrudPersonRepository.java
package com.mmnaseri.utils.spring.data.sample.repositories; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:47 PM) */ public interface ClearableSimpleCrudPersonRepository extends SimpleCrudPersonRepository { void clearRepo(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/RepositoryClearerMapping.java
spring-data-mock/src/test/java/com/mmnaseri/utils/spring/data/sample/repositories/RepositoryClearerMapping.java
package com.mmnaseri.utils.spring.data.sample.repositories; import com.mmnaseri.utils.spring.data.domain.RepositoryAware; import com.mmnaseri.utils.spring.data.domain.impl.key.NoOpKeyGenerator; import com.mmnaseri.utils.spring.data.proxy.*; import com.mmnaseri.utils.spring.data.sample.models.Person; import org.hamcrest.Matchers; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 6:48 PM) */ @SuppressWarnings("unused") public class RepositoryClearerMapping implements RepositoryAware<ClearableSimpleCrudPersonRepository>, RepositoryFactoryConfigurationAware, RepositoryConfigurationAware, RepositoryFactoryAware { private ClearableSimpleCrudPersonRepository repository; @Override public void setRepository(ClearableSimpleCrudPersonRepository repository) { this.repository = repository; } public void clearRepo() { repository.deleteAll(); } @Override public void setRepositoryFactoryConfiguration(RepositoryFactoryConfiguration configuration) { assertThat(configuration, is(notNullValue())); } @Override public void setRepositoryConfiguration(RepositoryConfiguration repositoryConfiguration) { assertThat(repositoryConfiguration, is(notNullValue())); assertThat(repositoryConfiguration.getKeyGenerator(), is(notNullValue())); assertThat(repositoryConfiguration.getKeyGenerator(), is(instanceOf(NoOpKeyGenerator.class))); assertThat(repositoryConfiguration.getRepositoryMetadata(), is(notNullValue())); assertThat(repositoryConfiguration.getRepositoryMetadata().getEntityType(), is(Matchers.equalTo(Person.class))); assertThat(repositoryConfiguration.getRepositoryMetadata().getIdentifierProperty(), is("id")); assertThat(repositoryConfiguration.getRepositoryMetadata().getIdentifierType(), is(Matchers.equalTo(String.class))); assertThat(repositoryConfiguration.getRepositoryMetadata().getRepositoryInterface(), is(Matchers.equalTo(ClearableSimpleCrudPersonRepository.class))); assertThat(repositoryConfiguration.getBoundImplementations(), is(not(empty()))); assertThat(repositoryConfiguration.getBoundImplementations(), hasItem(RepositoryClearerMapping.class)); } @Override public void setRepositoryFactory(RepositoryFactory factory) { assertThat(factory, is(notNullValue())); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/string/DocumentReader.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/string/DocumentReader.java
package com.mmnaseri.utils.spring.data.string; import java.util.regex.Pattern; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ @SuppressWarnings("unused") public interface DocumentReader { /** * This will return the parts of document not yet read through by the reader * * @return the part of the document not processed by the reader */ String rest(); /** * This method will determine whether the indicated pattern can be found at this point in the * document or not * * @param pattern the lookup pattern * @return <code>true</code> if the pattern can be found */ boolean has(Pattern pattern); /** * This method will determine whether the indicated pattern can be found at this point in the * document or not * * @param pattern the lookup pattern * @return <code>true</code> if the pattern can be found */ boolean has(String pattern); /** * Determines whether we have hit the end of the document or not * * @return <code>true</code> if we have no more to go */ boolean hasMore(); /** * Will attempt to read the string matching the given parameter. If the string matched with this * pattern does not start at the current point in the document, the result will be considered to * be negative. * * @param pattern the compiled pattern to be matched against * @return the string read by the method, or <code>null</code> if it cannot be found * @see Pattern#compile(String) * @see Pattern#compile(String, int) */ String read(Pattern pattern); /** * Will attempt to read the string matching the given parameter. If the string matched with this * pattern does not start at the current point in the document, the result will be considered to * be negative. * * @param pattern the compiled pattern to be matched against * @return the string read by the method, or <code>null</code> if it cannot be found * @see Pattern#compile(String) * @see Pattern#compile(String, int) */ String read(String pattern); /** * This will attempt to read string matching the given pattern from the document at the current * point indicated by the cursor. If failed to do so, the method will be expected to throw an * exception or take corrective measures. * * @param pattern the regular to query for * @return the read string */ String expect(Pattern pattern); /** * This will attempt to read string matching the given pattern from the document at the current * point indicated by the cursor. If failed to do so, the method will be expected to throw an * exception or take corrective measures. * * @param pattern the regular to query for * @return the read string */ String expect(String pattern); /** * This will cause the state of the reading to be reset. The cursor will be set back to the * beginning of the document, and the line/column positioning data will be reset to their initial * value. */ void reset(); /** * Moves back the specified number of characters * * @param count character count to backtrack by */ void backtrack(int count); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/string/impl/DefaultDocumentReader.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/string/impl/DefaultDocumentReader.java
package com.mmnaseri.utils.spring.data.string.impl; import com.mmnaseri.utils.spring.data.error.ParserException; import com.mmnaseri.utils.spring.data.string.DocumentReader; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ @SuppressWarnings("unused") public class DefaultDocumentReader implements DocumentReader { private final String document; private int cursor; /** * Instantiates the reader while taking in the document to be read through * * @param document the document */ public DefaultDocumentReader(String document) { this.document = document; reset(); } /** * This will return the parts of document not yet read through by the reader * * @return the part of the document not processed by the reader */ @Override public String rest() { return document.substring(cursor); } /** * This method will determine whether the indicated pattern can be found at this point in the * document or not * * @param pattern the lookup pattern * @return <code>true</code> if the pattern can be found */ @Override public boolean has(Pattern pattern) { final Matcher matcher = pattern.matcher(rest()); return matcher.find() && matcher.start() == 0; } /** * This method will determine whether the indicated pattern can be found at this point in the * document or not * * @param pattern the lookup pattern * @return <code>true</code> if the pattern can be found */ @Override public boolean has(String pattern) { if (!pattern.startsWith("^")) { pattern = "^" + pattern; } return has(Pattern.compile(pattern, Pattern.DOTALL | Pattern.MULTILINE)); } /** * Determines whether we have hit the end of the document or not * * @return <code>true</code> if we have no more to go */ @Override public boolean hasMore() { return !rest().isEmpty(); } /** * Will attempt to read the string matching the given parameter. If the string matched with this * pattern does not start at the current point in the document, the result will be considered to * be negative. * * @param pattern the compiled pattern to be matched against * @return the string read by the method, or <code>null</code> if it cannot be found * @see Pattern#compile(String) * @see Pattern#compile(String, int) */ @Override public String read(Pattern pattern) { final Matcher matcher = pattern.matcher(rest()); if (matcher.find() && matcher.start() == 0) { cursor += matcher.group().length(); return matcher.group(); } return null; } /** * Will attempt to read the string matching the given parameter. If the string matched with this * pattern does not start at the current point in the document, the result will be considered to * be negative. * * @param pattern the compiled pattern to be matched against * @return the string read by the method, or <code>null</code> if it cannot be found * @see Pattern#compile(String) * @see Pattern#compile(String, int) */ @Override public String read(String pattern) { return read(Pattern.compile(pattern, Pattern.DOTALL | Pattern.MULTILINE)); } /** * This will attempt to read string matching the given pattern from the document at the current * point indicated by the cursor. If failed to do so, the method will be expected to throw an * exception or take corrective measures. * * @param pattern the regular to query for * @return the read string */ @Override public String expect(Pattern pattern) { final String token = read(pattern); if (token == null) { throw new ParserException( "Expected pattern '" + pattern.pattern() + "' was not encountered in document: " + document); } return token; } @Override public String expect(String pattern) { return expect(Pattern.compile(pattern, Pattern.DOTALL | Pattern.MULTILINE)); } /** * This will cause the state of the reading to be reset. The cursor will be set back to the * beginning of the document, and the line/column positioning data will be reset to their initial * value. */ @Override public void reset() { cursor = 0; } /** * Moves back the specified number of characters * * @param count character count to backtrack by */ @Override public void backtrack(int count) { cursor -= count; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Page.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Page.java
package com.mmnaseri.utils.spring.data.query; /** * This interface represents metadata about a pagination request * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public interface Page { /** @return the size of the page */ int getPageSize(); /** @return the maximum number of the items in each page */ int getPageNumber(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/DataFunction.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/DataFunction.java
package com.mmnaseri.utils.spring.data.query; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.store.DataStore; import java.util.List; /** * This interface encapsulates a data function. A data function is a function that applies to an * already aggregated selection of entities, and can return any value. * * <p>An example for a data function would be returning the number of items from a selection (count * function) or duplicating all the selected entities. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public interface DataFunction<R> { <K, E> R apply( DataStore<K, E> dataStore, QueryDescriptor query, RepositoryConfiguration configuration, List<E> selection); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/NullHandling.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/NullHandling.java
package com.mmnaseri.utils.spring.data.query; /** * This enum is used to indicate how null values should be handled when compared to non-null values. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public enum NullHandling { /** The null values should come before non-null values. */ NULLS_FIRST, /** The null values should appear last when compared to non-null values. */ NULLS_LAST, /** Pick one of the above as per the specifications of the underlying data store. */ DEFAULT }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/PageParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/PageParameterExtractor.java
package com.mmnaseri.utils.spring.data.query; /** * This interface will let us extract {@link Page} metadata for a given method invocation. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ public interface PageParameterExtractor extends ParameterMetadataExtractor<Page> {}
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/PropertyDescriptor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/PropertyDescriptor.java
package com.mmnaseri.utils.spring.data.query; /** * This interface represents metadata about a property * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/20/15) */ public interface PropertyDescriptor { /** * @return the path leading to the property * @see com.mmnaseri.utils.spring.data.tools.PropertyUtils#getPropertyValue(Object, String) */ String getPath(); /** @return the type of the property */ Class<?> getType(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/ParameterMetadataExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/ParameterMetadataExtractor.java
package com.mmnaseri.utils.spring.data.query; import com.mmnaseri.utils.spring.data.domain.Invocation; /** * This interface encapsulates the process of extracting metadata for a query execution from a given * query method invocation. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ @SuppressWarnings("WeakerAccess") public interface ParameterMetadataExtractor<E> { /** * Extracts the promised metadata as per this invocation. * * @param invocation the invocation * @return the promised metadata or {@literal null} if nothing relevant can be found */ E extract(Invocation invocation); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/SortParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/SortParameterExtractor.java
package com.mmnaseri.utils.spring.data.query; /** * This interface encapsulates the process of extracting {@link Sort} metadata from a given query * method invocation. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ public interface SortParameterExtractor extends ParameterMetadataExtractor<Sort> {}
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/DataFunctionRegistry.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/DataFunctionRegistry.java
package com.mmnaseri.utils.spring.data.query; import com.mmnaseri.utils.spring.data.error.FunctionNotFoundException; import java.util.Set; /** * A data function registry lets you register and maintain a set of data functions by name. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("unused") public interface DataFunctionRegistry { /** * Registers a new data function * * @param name the name under which the function will be known * @param function the actual function */ void register(String name, DataFunction<?> function); /** * Finds the function associated with the given name. If a function with that name does not exist, * throws an exception. * * @param name the name of the function. * @return the data function * @throws FunctionNotFoundException If no function for the provided name can be found. */ DataFunction<?> getFunction(String name); /** @return the set of all registered functions */ Set<String> getFunctions(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/QueryDescriptor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/QueryDescriptor.java
package com.mmnaseri.utils.spring.data.query; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.domain.InvocationMatcher; import com.mmnaseri.utils.spring.data.domain.Parameter; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; import java.util.List; /** * This interface encapsulates everything that we can know about a query. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public interface QueryDescriptor extends InvocationMatcher { /** * @return the repository factory configuration that were used when the current query was * discovered */ RepositoryFactoryConfiguration getConfiguration(); /** @return metadata pertaining to the repository to which this query belongs */ RepositoryMetadata getRepositoryMetadata(); /** @return whether query results are expected to be distinct */ boolean isDistinct(); /** * @return the function name that should be applied to the entities selected as per this query. * Could be {@literal null} to indicate that no function should be applied. */ String getFunction(); /** * @return the maximum number of items this query is expected to return. A non-positive value * indicates no limit. */ int getLimit(); /** * Given an actual, runtime invocation, returns the page metadata for that invocation as per this * query, or {@literal null} if no pagination was indicated. * * @param invocation the invocation * @return the pagination metadata */ Page getPage(Invocation invocation); /** * Given an actual, runtime invocation, returns the sort metadata for that invocation as per this * query, or returns {@literal null} to indicate no ordering is required. * * @param invocation the invocation * @return the sort metadata */ Sort getSort(Invocation invocation); /** * @return a list of decision branches which forms this query. Each decision branch is a set of * conjunctive criteria about any single entity. This means to be evaluated to {@literal * true}, all of the parameters in that branch must match the entity. Decision branches are * disjunctive towards each other, meaning that the moment one of them was evaluated to * {@literal true} the rest will be disregarded. */ List<List<Parameter>> getBranches(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Order.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Order.java
package com.mmnaseri.utils.spring.data.query; /** * This interface represents metadata about an ordering based on a single property. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public interface Order { /** @return the direction of the sort */ SortDirection getDirection(); /** @return the property for which the ordering is taking place */ String getProperty(); /** @return how null values should be handled */ NullHandling getNullHandling(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/SortDirection.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/SortDirection.java
package com.mmnaseri.utils.spring.data.query; /** * This enum is used to indicate the direction of a sort. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public enum SortDirection { /** Items should be sorted as per their natural ordering */ ASCENDING, /** Items should be sorted in the reverse direction of their natural ordering */ DESCENDING }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Sort.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/Sort.java
package com.mmnaseri.utils.spring.data.query; import java.util.List; /** * This interface represents a sort specification, which is in turn a collection of {@link Order * orders}. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public interface Sort { /** @return the orders comprising this sort specification */ List<Order> getOrders(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/WrappedSortParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/WrappedSortParameterExtractor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.error.RepositoryDefinitionException; import com.mmnaseri.utils.spring.data.query.Sort; import com.mmnaseri.utils.spring.data.query.SortParameterExtractor; /** * This extractor will return the statically defined sort metadata for a query method (as parsed * from the method name). * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/20/15) */ public class WrappedSortParameterExtractor implements SortParameterExtractor { private final Sort sort; public WrappedSortParameterExtractor(Sort sort) { if (sort == null) { throw new RepositoryDefinitionException( null, "Predefined sort method must not resolve to null"); } this.sort = sort; } @Override public Sort extract(Invocation invocation) { if (invocation == null) { throw new InvalidArgumentException("Invocation cannot be null"); } return sort; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutablePage.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutablePage.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.query.Page; /** * This is an immutable page * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ @SuppressWarnings("WeakerAccess") public class ImmutablePage implements Page { private final int pageSize; private final int pageNumber; public ImmutablePage(int pageSize, int pageNumber) { this.pageSize = pageSize; this.pageNumber = pageNumber; } @Override public int getPageSize() { return pageSize; } @Override public int getPageNumber() { return pageNumber; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/PageablePageParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/PageablePageParameterExtractor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.query.Page; import com.mmnaseri.utils.spring.data.query.PageParameterExtractor; import org.springframework.data.domain.Pageable; /** * This extractor will expect to see a {@link Pageable} as the last parameter passed to a query * method invocation, and converts that to a valid page. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ public class PageablePageParameterExtractor implements PageParameterExtractor { private final int index; public PageablePageParameterExtractor(int index) { this.index = index; } @Override public Page extract(Invocation invocation) { if (invocation == null) { throw new InvalidArgumentException("Invocation cannot be null"); } final Object value = invocation.getArguments()[index]; if (value == null) { throw new InvalidArgumentException("Page value should not be empty"); } if (value instanceof Pageable) { final Pageable pageable = (Pageable) value; return new ImmutablePage(pageable.getPageSize(), pageable.getPageNumber()); } throw new InvalidArgumentException( "No valid value was passed to deduce the paging description from"); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/PageableSortParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/PageableSortParameterExtractor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.query.Sort; import org.springframework.data.domain.Pageable; /** * This extractor expects to see a {@link Pageable} passed as the last argument to a query method * call and tries to ask the pageable for the sort metadata. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ public class PageableSortParameterExtractor extends AbstractSortParameterExtractor { private final int index; public PageableSortParameterExtractor(int index) { this.index = index; } @Override public Sort extract(Invocation invocation) { if (invocation == null) { throw new InvalidArgumentException("Invocation cannot be null"); } final Object value = invocation.getArguments()[index]; if (value == null) { throw new InvalidArgumentException("Page value should not be empty"); } if (value instanceof Pageable) { final Pageable pageable = (Pageable) value; final org.springframework.data.domain.Sort sort = pageable.getSort(); return getSort(sort); } throw new InvalidArgumentException( "No valid value was passed to deduce the sort description from"); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/CountDataFunction.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/CountDataFunction.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.query.DataFunction; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.store.DataStore; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.List; /** * This data function provides support for the {@literal count} aggregator over a selection. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("WeakerAccess") public class CountDataFunction implements DataFunction<Long> { private static final Log log = LogFactory.getLog(CountDataFunction.class); @Override public <K, E> Long apply( DataStore<K, E> dataStore, QueryDescriptor query, RepositoryConfiguration repositoryConfiguration, List<E> selection) { if (selection == null) { log.error("Cannot calculate the count if the selection is null"); throw new InvalidArgumentException("Selection cannot be null"); } return ((Integer) selection.size()).longValue(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutableSort.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutableSort.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.query.Order; import com.mmnaseri.utils.spring.data.query.Sort; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * This is an immutable sort * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public class ImmutableSort implements Sort { private final List<Order> orders; public ImmutableSort(List<Order> orders) { this.orders = new ArrayList<>(); if (orders != null) { for (Order order : orders) { this.orders.add(new ImmutableOrder(order)); } } } @Override public List<Order> getOrders() { return Collections.unmodifiableList(orders); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutablePropertyDescriptor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutablePropertyDescriptor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.query.PropertyDescriptor; /** * This is an immutable property descriptor * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/20/15) */ public class ImmutablePropertyDescriptor implements PropertyDescriptor { private final String path; private final Class<?> type; public ImmutablePropertyDescriptor(String path, Class<?> type) { this.path = path; this.type = type; } @Override public String getPath() { return path; } @Override public Class<?> getType() { return type; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DeleteDataFunction.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DeleteDataFunction.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.error.DataFunctionException; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.proxy.RepositoryConfiguration; import com.mmnaseri.utils.spring.data.query.DataFunction; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.store.DataStore; import com.mmnaseri.utils.spring.data.tools.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.LinkedList; import java.util.List; /** * This function provides support for the delete data operation, by issuing a delete request for * every selected entity to the underlying data store. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("WeakerAccess") public class DeleteDataFunction implements DataFunction<List<?>> { private static final Log log = LogFactory.getLog(DeleteDataFunction.class); @Override public <K, E> List<E> apply( DataStore<K, E> dataStore, QueryDescriptor query, RepositoryConfiguration repositoryConfiguration, List<E> selection) { if (dataStore == null) { log.error("Cannot delete entities when the data store is null"); throw new InvalidArgumentException("Data store cannot be null"); } if (query == null) { log.error("Cannot delete entities when the query is null"); throw new InvalidArgumentException("Query cannot be null"); } if (selection == null) { log.error("Cannot delete entities when the selection is null"); throw new InvalidArgumentException("Selection cannot be null"); } final String identifier = query.getRepositoryMetadata().getIdentifierProperty(); log.info("Using property " + identifier + " to delete the entities"); final List<E> deleted = new LinkedList<>(); for (E item : selection) { final Object key; try { key = PropertyUtils.getPropertyValue(item, identifier); } catch (Exception e) { log.error("The value of property " + identifier + " could not be read "); throw new DataFunctionException( "Failed to read property value for property " + identifier, e); } if (key == null) { log.error("Cannot delete an entity when the identifier property has been set to null"); throw new DataFunctionException( "Cannot delete an entity without the key property being set: " + identifier); } //noinspection unchecked if (dataStore.delete((K) key)) { deleted.add(item); } } log.error("Deleted " + deleted.size() + " entities as the result of the delete call"); return deleted; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DefaultQueryDescriptor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DefaultQueryDescriptor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.domain.InvocationMatcher; import com.mmnaseri.utils.spring.data.domain.Modifier; import com.mmnaseri.utils.spring.data.domain.Operator; import com.mmnaseri.utils.spring.data.domain.Parameter; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import com.mmnaseri.utils.spring.data.proxy.RepositoryFactoryConfiguration; import com.mmnaseri.utils.spring.data.query.Page; import com.mmnaseri.utils.spring.data.query.PageParameterExtractor; import com.mmnaseri.utils.spring.data.query.QueryDescriptor; import com.mmnaseri.utils.spring.data.query.Sort; import com.mmnaseri.utils.spring.data.query.SortParameterExtractor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; import java.util.List; /** * This is a mutable query descriptor that you can use to describe what a query does. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/20/15) */ public class DefaultQueryDescriptor implements QueryDescriptor { private static final Log log = LogFactory.getLog(InvocationMatcher.class); private final boolean distinct; private final String function; private final int limit; private final PageParameterExtractor pageExtractor; private final SortParameterExtractor sortExtractor; private final List<List<Parameter>> branches; private final RepositoryFactoryConfiguration configuration; private final RepositoryMetadata repositoryMetadata; public DefaultQueryDescriptor( boolean distinct, String function, int limit, PageParameterExtractor pageExtractor, SortParameterExtractor sortExtractor, List<List<Parameter>> branches, RepositoryFactoryConfiguration configuration, RepositoryMetadata repositoryMetadata) { this.distinct = distinct; this.function = function; this.limit = limit; this.pageExtractor = pageExtractor; this.sortExtractor = sortExtractor; this.branches = branches; this.configuration = configuration; this.repositoryMetadata = repositoryMetadata; } @Override public RepositoryFactoryConfiguration getConfiguration() { return configuration; } @Override public RepositoryMetadata getRepositoryMetadata() { return repositoryMetadata; } @Override public boolean isDistinct() { return distinct; } @Override public String getFunction() { return function; } @Override public int getLimit() { return limit; } @Override public Page getPage(Invocation invocation) { return pageExtractor == null ? null : pageExtractor.extract(invocation); } @Override public Sort getSort(Invocation invocation) { return sortExtractor == null ? null : sortExtractor.extract(invocation); } @Override public List<List<Parameter>> getBranches() { return branches; } @Override public boolean matches(Object entity, Invocation invocation) { log.info("Matching " + entity + " against " + invocation); final List<List<Parameter>> branches = getBranches(); if (branches.isEmpty()) { return entity != null; } final BeanWrapper wrapper = new BeanWrapperImpl(entity); for (List<Parameter> branch : branches) { boolean matches = true; for (Parameter parameter : branch) { final boolean ignoreCase; ignoreCase = parameter.getModifiers().contains(Modifier.IGNORE_CASE); Object value = wrapper.getPropertyValue(parameter.getPath()); if (ignoreCase && value instanceof String) { value = ((String) value).toLowerCase(); } final Operator operator = parameter.getOperator(); final Object[] properties = new Object[operator.getOperands()]; for (int i = 0; i < operator.getOperands(); i++) { properties[i] = invocation.getArguments()[parameter.getIndices()[i]]; if (ignoreCase && properties[i] != null && properties[i] instanceof String) { properties[i] = ((String) properties[i]).toLowerCase(); } } if (!operator.getMatcher().matches(parameter, value, properties)) { matches = false; break; } } if (matches) { return true; } } return false; } @Override public String toString() { return (getFunction() != null ? getFunction() + " " : "") + (isDistinct() ? "distinct " : "") + getBranches(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DirectSortParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DirectSortParameterExtractor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.domain.Invocation; import com.mmnaseri.utils.spring.data.error.InvalidArgumentException; import com.mmnaseri.utils.spring.data.query.Sort; /** * This extractor will expect to receive a {@link org.springframework.data.domain.Sort} object via * the very last parameter of a query method invocation. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ public class DirectSortParameterExtractor extends AbstractSortParameterExtractor { private final int index; public DirectSortParameterExtractor(int index) { this.index = index; } @Override public Sort extract(Invocation invocation) { if (invocation == null) { throw new InvalidArgumentException("Invocation cannot be null"); } final Object value = invocation.getArguments()[index]; if (value == null) { throw new InvalidArgumentException("Page value should not be empty"); } if (value instanceof org.springframework.data.domain.Sort) { return getSort((org.springframework.data.domain.Sort) value); } throw new InvalidArgumentException( "No valid value was passed to deduce the paging description from"); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutableOrder.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/ImmutableOrder.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.query.NullHandling; import com.mmnaseri.utils.spring.data.query.Order; import com.mmnaseri.utils.spring.data.query.SortDirection; /** * This is an immutable order. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ @SuppressWarnings("WeakerAccess") public class ImmutableOrder implements Order { private final SortDirection direction; private final String property; private final NullHandling nullHandling; public ImmutableOrder(Order order) { this(order.getDirection(), order.getProperty(), order.getNullHandling()); } public ImmutableOrder(SortDirection direction, String property, NullHandling nullHandling) { this.direction = direction; this.property = property; this.nullHandling = nullHandling; } @Override public SortDirection getDirection() { return direction; } @Override public String getProperty() { return property; } @Override public NullHandling getNullHandling() { return nullHandling; } @Override public String toString() { return property + " " + direction; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/AbstractSortParameterExtractor.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/AbstractSortParameterExtractor.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.query.NullHandling; import com.mmnaseri.utils.spring.data.query.Order; import com.mmnaseri.utils.spring.data.query.Sort; import com.mmnaseri.utils.spring.data.query.SortDirection; import com.mmnaseri.utils.spring.data.query.SortParameterExtractor; import java.util.ArrayList; import java.util.List; import static org.springframework.data.domain.Sort.Direction.ASC; import static org.springframework.data.domain.Sort.NullHandling.NULLS_FIRST; import static org.springframework.data.domain.Sort.NullHandling.NULLS_LAST; /** * This class will provide support for converting {@link org.springframework.data.domain.Sort Spring * Data sort objects} into {@link Sort sort objects} defined within this framework. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/19/15) */ @SuppressWarnings("WeakerAccess") public abstract class AbstractSortParameterExtractor implements SortParameterExtractor { /** * Given a sort parameter from the Spring Data framework, will determine the appropriate sort * metadata compatible with this framework * * @param sort the sort specification * @return converted sort metadata */ protected Sort getSort(org.springframework.data.domain.Sort sort) { final List<Order> orders = new ArrayList<>(); for (org.springframework.data.domain.Sort.Order order : sort) { final SortDirection sortDirection = order.getDirection().equals(ASC) ? SortDirection.ASCENDING : SortDirection.DESCENDING; final NullHandling nullHandling = order.getNullHandling().equals(NULLS_FIRST) ? NullHandling.NULLS_FIRST : (order.getNullHandling().equals(NULLS_LAST) ? NullHandling.NULLS_LAST : NullHandling.DEFAULT); orders.add(new ImmutableOrder(sortDirection, order.getProperty(), nullHandling)); } return new ImmutableSort(orders); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DefaultDataFunctionRegistry.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/query/impl/DefaultDataFunctionRegistry.java
package com.mmnaseri.utils.spring.data.query.impl; import com.mmnaseri.utils.spring.data.error.DuplicateFunctionException; import com.mmnaseri.utils.spring.data.error.FunctionNotFoundException; import com.mmnaseri.utils.spring.data.query.DataFunction; import com.mmnaseri.utils.spring.data.query.DataFunctionRegistry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** * This class provides support for registering data functions. Also, it comes with the option to * register the default functions out-of-the-box. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("WeakerAccess") public class DefaultDataFunctionRegistry implements DataFunctionRegistry { private static final Log log = LogFactory.getLog(DefaultDataFunctionRegistry.class); private final Map<String, DataFunction<?>> functions; public DefaultDataFunctionRegistry() { this(true); } public DefaultDataFunctionRegistry(boolean registerDefaults) { functions = new ConcurrentHashMap<>(); if (registerDefaults) { log.info("Registering the default functions"); register("count", new CountDataFunction()); register("delete", new DeleteDataFunction()); } } @Override public void register(String name, DataFunction<?> function) { if (functions.containsKey(name)) { log.error( "Cannot register a function with name " + name + " because that name is already taken"); throw new DuplicateFunctionException(name); } log.info("Registering function with name " + name); functions.put(name, function); } @Override public DataFunction<?> getFunction(String name) { if (!functions.containsKey(name)) { log.error("No function could be found with name " + name); throw new FunctionNotFoundException(name); } return functions.get(name); } @Override public Set<String> getFunctions() { return functions.keySet(); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/StringUtils.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/StringUtils.java
package com.mmnaseri.utils.spring.data.tools; import java.util.Objects; /** * Utility class for working with String objects. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ @SuppressWarnings("WeakerAccess") public final class StringUtils { private StringUtils() { throw new UnsupportedOperationException(); } /** * Returns the same string as the original value, with the first letter turned to lower case * * @param expression the expression * @return the un-capitalized version of the expression */ public static String uncapitalize(String expression) { return Objects.requireNonNull(expression, "String value cannot be null").isEmpty() ? expression : expression.substring(0, 1).toLowerCase() + expression.substring(1); } /** * Returns the same string as the original value, with the first letter turned to upper case * * @param expression the expression * @return the un-capitalized version of the expression */ public static String capitalize(String expression) { return Objects.requireNonNull(expression, "String value cannot be null").isEmpty() ? expression : expression.substring(0, 1).toUpperCase() + expression.substring(1); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/PropertyUtils.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/PropertyUtils.java
package com.mmnaseri.utils.spring.data.tools; import com.mmnaseri.utils.spring.data.query.PropertyDescriptor; import com.mmnaseri.utils.spring.data.query.impl.ImmutablePropertyDescriptor; import com.mmnaseri.utils.spring.data.string.DocumentReader; import com.mmnaseri.utils.spring.data.string.impl.DefaultDocumentReader; import org.springframework.util.ReflectionUtils; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Utility class for taking care of all common property/reflection related operations * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/17/15) */ public final class PropertyUtils { /** Used for storing all primitive-object mappings */ private static final Map<Class<?>, Class<?>> types = new HashMap<>(); static { types.put(int.class, Integer.class); types.put(short.class, Short.class); types.put(long.class, Long.class); types.put(double.class, Double.class); types.put(char.class, Character.class); types.put(float.class, Float.class); types.put(boolean.class, Boolean.class); types.put(byte.class, Byte.class); } private PropertyUtils() { throw new UnsupportedOperationException(); } /** * Given a property path will find out the proper way of accessing that property and return the * value given the current context. The property path can use the "dot notation" to indicate * nested properties (so that "x.y.z" would mean {@literal context.getX().getY().getZ()}). * * <p>Properties can be accessed via getter methods or fields, with getter methods taking * precedence. If a property doesn't exist at any given point, an error will be raised. If any * property is set to {@literal null}, the chain evaluation will stop and {@literal null} will be * returned. This means that if we are requesting access to the valid nested property {@literal * x.y.z}, and {@literal y} is {@literal null}, instead of failing with an error, the reader will * return {@literal null}. * * @param context the object to evaluate the property path against * @param property the property path as outlined above * @return the value of the property */ public static Object getPropertyValue(Object context, String property) { final String[] chain = property.split("\\."); final List<Object> accessors = new ArrayList<>(); Class<?> type = context.getClass(); final StringBuilder path = new StringBuilder(); for (String current : chain) { if (path.length() > 0) { path.append('.'); } path.append(current); final Method getter = ReflectionUtils.findMethod(type, "get" + StringUtils.capitalize(current)); if (getter != null) { accessors.add(getter); type = getter.getReturnType(); } else { final Field field = ReflectionUtils.findField(type, current); if (field != null) { field.setAccessible(true); accessors.add(field); type = field.getType(); } else { throw new IllegalStateException( "Cannot find property `" + path + "` on type `" + context.getClass() + "`"); } } } Object result = context; for (Object accessor : accessors) { try { if (accessor instanceof Method) { final Method method = (Method) accessor; result = method.invoke(result); } else { final Field field = (Field) accessor; result = field.get(result); } } catch (Exception e) { throw new IllegalStateException("Failed to access property `" + property + "`", e); } if (result == null) { return null; } } return result; } /** * Sets the value of the given property to the provided value. The property path will follow the * same rules as defined in {@link #getPropertyValue(Object, String)}, with the exception that if * any of the parent properties in the nested path leading to the very last property (the one * being modified) is {@literal null} an exception is thrown. * * @param context the context against which the property path will be evaluated * @param property the property path * @param value the value to set for the property * @return the actual object that was changed. So, if the property path was {@literal x.y.z} on * object {@literal context}, the returned value would be equivalent to {@literal * context.getX().getY()}, since we are modifying the {@literal z} property of the {@literal * y} object accessible by the mentioned chain of accessors. */ public static Object setPropertyValue(Object context, String property, Object value) { if (property.contains(".")) { final String[] split = property.split("\\.", 2); final Object propertyValue = getPropertyValue(context, split[0]); if (propertyValue == null) { throw new IllegalStateException( "Root property " + split[0] + " was null when reading " + property); } return setPropertyValue(propertyValue, split[1], value); } Method setter = null; final String setterName = "set" + StringUtils.capitalize(property); if (value != null) { setter = ReflectionUtils.findMethod(context.getClass(), setterName, value.getClass()); } else { for (Method method : ReflectionUtils.getAllDeclaredMethods(context.getClass())) { if (method.getName().equals(setterName) && method.getParameterTypes().length == 1 && !method.getParameterTypes()[0].isPrimitive()) { setter = method; break; } } } if (setter != null) { try { setter.invoke(context, value); return context; } catch (Exception e) { throw new IllegalStateException( "Failed to set property value through the setter method " + setter); } } else { final Field field = ReflectionUtils.findField(context.getClass(), property); if (field != null) { if (Modifier.isFinal(field.getModifiers())) { field.setAccessible(true); } try { field.set(context, value); return context; } catch (Exception e) { throw new IllegalStateException( "Failed to set property value through the field " + field); } } } throw new IllegalStateException( "Failed to find property " + property + " on " + context.getClass()); } /** * Given a property expression which contains CamelCase words will try to look up the property * path leading up to the appropriate nested property. Property names will be matched eagerly, so * that expression {@literal XxYy} will match property {@literal XxYy} if it exists, rather than * {@literal Xx} first. * * <p>If you wan to force the parser to avoid eager evaluation, you can insert an underscore * ({@literal _}) character in place of the nested property separator. Thus, {@literal Xx_Yy} will * force the parser to consider {@literal Xx} and only that property will satisfy the parser. * * @param domainType the domain type that will be used to evaluate the property expression * @param expression the property expression as explained above * @return a property descriptor equipped with a proper property path (as described in {@link * #getPropertyValue(Object, String)}) to let us read from and write to the described * property. */ public static PropertyDescriptor getPropertyDescriptor(Class<?> domainType, String expression) { String search = expression; final String followUp; if (search.contains("_")) { final String[] split = search.split("_", 2); search = split[0]; followUp = split[1]; } else { followUp = ""; } Class<?> context = domainType; final DocumentReader reader = new DefaultDocumentReader(search); final List<String> tokens = new ArrayList<>(); while (reader.hasMore()) { tokens.add(reader.expect("[A-Z][a-z]*")); } int cursor = 0; final StringBuilder path = new StringBuilder(); while (cursor < tokens.size()) { boolean found = false; for (int i = tokens.size(); i >= cursor; i--) { final String propertyName = getPropertyName(tokens, cursor, i); final Method getter = ReflectionUtils.findMethod(context, "get" + StringUtils.capitalize(propertyName)); if (getter != null) { context = getter.getReturnType(); cursor = i; found = true; path.append(".").append(propertyName); break; } final Field field = ReflectionUtils.findField(context, propertyName); if (field != null) { context = field.getType(); cursor = i; found = true; path.append(".").append(propertyName); break; } } if (!found) { throw new IllegalStateException( "Could not find property `" + getPropertyName(tokens, cursor, tokens.size()) + "` on `" + context + "`"); } } if (!followUp.isEmpty()) { final PropertyDescriptor descriptor = getPropertyDescriptor(context, followUp); return new ImmutablePropertyDescriptor( path.substring(1) + "." + descriptor.getPath(), descriptor.getType()); } return new ImmutablePropertyDescriptor(path.substring(1), context); } /** * Given a list of tokens (all of which are capitalized) this method composes a possible property * name, so that {@literal ["Xx", "Yy", "Zz"]} becomes {@literal "xxYyZz"}. * * @param tokens the list of all tokens * @param from the start index * @param to the end index * @return composed property name */ private static String getPropertyName(List<String> tokens, int from, int to) { final StringBuilder builder = new StringBuilder(); for (int i = from; i < to; i++) { builder.append(tokens.get(i)); } return StringUtils.uncapitalize(builder.toString()); } /** * Returns the object type for the provided type. * * @param type the type to find out the object type for * @return the object type for the type if it is a primitive, or the type itself if it is not. */ public static Class<?> getTypeOf(Class<?> type) { if (type.isPrimitive()) { return types.get(type); } else { return type; } } /** * Given a getter method finds out the property name for the getter * * @param getter the getter method * @return the name of the property for the getter method */ public static String getPropertyName(Method getter) { return StringUtils.uncapitalize(getter.getName().substring(3)); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/GetterMethodFilter.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/GetterMethodFilter.java
package com.mmnaseri.utils.spring.data.tools; import org.springframework.util.ReflectionUtils; import java.lang.reflect.Method; /** * This filter will only accept methods that can be getters for properties (excluding the `is...` * format usually used for {@literal boolean} types). * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/23/15) */ public class GetterMethodFilter implements ReflectionUtils.MethodFilter { @Override public boolean matches(Method method) { return method.getName().matches("get[A-Z].*") && !void.class.equals(method.getReturnType()) && method.getParameterTypes().length == 0; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/CollectionInstanceUtils.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/tools/CollectionInstanceUtils.java
package com.mmnaseri.utils.spring.data.tools; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Deque; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Set; import java.util.Stack; import java.util.TreeSet; import java.util.Vector; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.PriorityBlockingQueue; /** * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/24/15) */ public final class CollectionInstanceUtils { private CollectionInstanceUtils() { throw new UnsupportedOperationException(); } /** * Given any of the known collection types, this method will return an instance of the collection. * * @param collectionType the type of the collection * @return the collection instance */ public static Collection<?> getCollection(Class<?> collectionType) { if (HashSet.class.equals(collectionType)) { return new HashSet<>(); } else if (TreeSet.class.equals(collectionType)) { return new TreeSet<>(); } else if (CopyOnWriteArraySet.class.equals(collectionType)) { return new CopyOnWriteArraySet<>(); } else if (LinkedHashSet.class.equals(collectionType)) { return new LinkedHashSet<>(); } else if (ArrayList.class.equals(collectionType)) { return new ArrayList<>(); } else if (LinkedList.class.equals(collectionType)) { return new LinkedList<>(); } else if (Vector.class.equals(collectionType)) { return new Vector<>(); } else if (Stack.class.equals(collectionType)) { return new Stack<>(); } else if (PriorityQueue.class.equals(collectionType)) { return new PriorityQueue<>(); } else if (PriorityBlockingQueue.class.equals(collectionType)) { return new PriorityBlockingQueue<>(); } else if (ArrayDeque.class.equals(collectionType)) { return new ArrayDeque<>(); } else if (ConcurrentLinkedQueue.class.equals(collectionType)) { return new ConcurrentLinkedQueue<>(); } else if (LinkedBlockingQueue.class.equals(collectionType)) { return new LinkedBlockingQueue<>(); } else if (LinkedBlockingDeque.class.equals(collectionType)) { return new LinkedBlockingDeque<>(); } else if (List.class.equals(collectionType)) { return new LinkedList<>(); } else if (Set.class.equals(collectionType)) { return new HashSet<>(); } else if (Queue.class.equals(collectionType)) { return new PriorityQueue<>(); } else if (Deque.class.equals(collectionType)) { return new ArrayDeque<>(); } else if (Collection.class.equals(collectionType)) { return new LinkedList<>(); } throw new IllegalArgumentException("Unsupported collection type: " + collectionType); } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactory.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactory.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; /** * This interface encapsulates the process of instantiating a repository. A repository factory is * needed to properly set up a repository instance. * * <p>A default implementation is provided via {@link * com.mmnaseri.utils.spring.data.proxy.impl.DefaultRepositoryFactory default repositor factory}. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public interface RepositoryFactory { /** * Creates an instance of the repository as per the provided configuration. * * @param keyGenerator the key generator to use when inserting items (if auto generation is * required). You can specify a {@literal null} key generator to signify that {@link * RepositoryFactoryConfiguration#getDefaultKeyGenerator() the fallback key generator} should * be used when generating keys. * @param repositoryInterface the repository interface which we want to mock * @param implementations all the concrete classes that can be used to figure out method mappings * @param <E> the type of the interface * @return a prepared instance of the repository * @throws com.mmnaseri.utils.spring.data.error.RepositoryMockException should anything go wrong */ <E> E getInstance( KeyGenerator<?> keyGenerator, Class<E> repositoryInterface, Class... implementations); /** @return the configuration bound to this repository factory */ RepositoryFactoryConfiguration getConfiguration(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryConfigurationAware.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryConfigurationAware.java
package com.mmnaseri.utils.spring.data.proxy; /** * This interface is used when an implementing class needs to know about the repository factory * configuration. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/9/15) */ public interface RepositoryFactoryConfigurationAware extends DependencyAware { /** * This method is called to inject the repository factory configuration * * @param configuration the configuration */ void setRepositoryFactoryConfiguration(RepositoryFactoryConfiguration configuration); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryAware.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryAware.java
package com.mmnaseri.utils.spring.data.proxy; /** * Indicates that the implementing class needs to know about the repository factory. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/12/16, 1:34 PM) */ public interface RepositoryFactoryAware extends DependencyAware { /** * Used to inject the repository factory into the implementing class * * @param factory the factory */ void setRepositoryFactory(RepositoryFactory factory); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryConfigurationAware.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryConfigurationAware.java
package com.mmnaseri.utils.spring.data.proxy; /** * Used to passed the repository configuration to implementing classes. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/10/16) */ public interface RepositoryConfigurationAware extends DependencyAware { /** * Called when the bound implementation class needs to know about the repository configuration. * * @param repositoryConfiguration the repository configuration */ void setRepositoryConfiguration(RepositoryConfiguration repositoryConfiguration); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/TypeMappingContext.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/TypeMappingContext.java
package com.mmnaseri.utils.spring.data.proxy; import java.util.List; /** * This interface encapsulates a context for holding mappings for a given repository type. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/8/15) */ public interface TypeMappingContext { /** * Registers a mapping that should be honored for all repositories that are a subtype of the * provided repository type. This means that if you register an implementation for {@link Object} * all repositories will inherit this mapping. * * @param repositoryType the repository (super) type * @param implementation the implementation type */ void register(Class<?> repositoryType, Class<?> implementation); /** * Given a repository type returns all concrete classes that could be used for that repository's * mappings * * @param repositoryType the repository type * @return the list of all possible mappings */ List<Class<?>> getImplementations(Class<?> repositoryType); /** * Given a repository type, will look up all possible mappings and creates {@link TypeMapping * mapping} objects from those * * @param repositoryType the repository type * @return a list of applicable mappings in the order in which they were registered */ List<TypeMapping<?>> getMappings(Class<?> repositoryType); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryConfiguration.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryFactoryConfiguration.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadataResolver; import com.mmnaseri.utils.spring.data.domain.impl.MethodQueryDescriptionExtractor; import com.mmnaseri.utils.spring.data.proxy.impl.NonDataOperationInvocationHandler; import com.mmnaseri.utils.spring.data.query.DataFunctionRegistry; import com.mmnaseri.utils.spring.data.store.DataStoreEventListenerContext; import com.mmnaseri.utils.spring.data.store.DataStoreRegistry; /** * This class will be used to hold all the pieces of information required to instantiate a * repository. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/8/15) */ public interface RepositoryFactoryConfiguration { /** @return the repository metadata resolver */ RepositoryMetadataResolver getRepositoryMetadataResolver(); /** @return the description extractor used to extract query metadata from a query method */ MethodQueryDescriptionExtractor getDescriptionExtractor(); /** @return the function registry containing all the functions used when executing the queries */ DataFunctionRegistry getFunctionRegistry(); /** @return the data store registry */ DataStoreRegistry getDataStoreRegistry(); /** @return the result adapter context */ ResultAdapterContext getResultAdapterContext(); /** @return the type mapping context */ TypeMappingContext getTypeMappingContext(); /** @return the data store event listener context */ DataStoreEventListenerContext getEventListenerContext(); /** @return the non-data operation invocation handler */ NonDataOperationInvocationHandler getOperationInvocationHandler(); /** * @return the default key generator that should be used as a fallback when no key generator is * specified */ KeyGenerator<?> getDefaultKeyGenerator(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/TypeMapping.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/TypeMapping.java
package com.mmnaseri.utils.spring.data.proxy; /** * This interface represents a value object used for storing mapping information for a single type * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public interface TypeMapping<E> { /** @return the type of the mapped class */ Class<E> getType(); /** @return an instance of the mapped class */ E getInstance(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/NonDataOperationHandler.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/NonDataOperationHandler.java
package com.mmnaseri.utils.spring.data.proxy; import java.lang.reflect.Method; /** * This interface encapsulates how a non-data operation should be handled. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/8/16) */ @SuppressWarnings("unused") public interface NonDataOperationHandler { /** * Used to find out if the given invocation on the indicated proxy object can be handled by this * handler. * * @param proxy the proxy * @param method the method * @param args the arguments passed to the method * @return {@literal true} if this handler can handle the given invocation. */ boolean handles(Object proxy, Method method, Object... args); /** * Used to handle the invocation. It is assumed that prior to calling this method, the caller has * already verified (using {@link #handles(Object, Method, Object...)}) that the handler can * indeed handle this method invocation. * * @param proxy the proxy object * @param method the method being called * @param args the arguments * @return the result */ Object invoke(Object proxy, Method method, Object... args); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultConverter.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultConverter.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.Invocation; /** * This interface encapsulates the process of converting a result from one type to the other. * * <p>This is different from adapting results since conversion doesn't involve mandatory operations * and can go through without any change to the original value. Also, converters are chained, so * that the result of one is passed to the next and so one, whereas with adapters, you have a single * adapter suitable for the current situation that operates on the result. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/28/15) */ public interface ResultConverter { /** * Called when we need to convert the result * * @param invocation the invocation for which the conversion is happening * @param original the original value * @return the converted value (or the original value if no conversion happened) */ Object convert(Invocation invocation, Object original); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/DataOperationResolver.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/DataOperationResolver.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.store.DataStoreOperation; import java.lang.reflect.Method; /** * This interface encapsulates the process of resolving the handler for a single unit of work when * interacting with an underlying {@link com.mmnaseri.utils.spring.data.store.DataStore data store}. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public interface DataOperationResolver { /** * Resolves the data store operation from the given method * * @param method the method for which a data operation is required. * @return the resolved operation. */ DataStoreOperation<?, ?, ?> resolve(Method method); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryConfiguration.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/RepositoryConfiguration.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.KeyGenerator; import com.mmnaseri.utils.spring.data.domain.RepositoryMetadata; import java.util.List; /** * This interface represents all the pieces of information that were used to instantiate a * repository instance. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (10/12/15) */ public interface RepositoryConfiguration { /** @return the repository metadata */ RepositoryMetadata getRepositoryMetadata(); /** @return the key generator */ KeyGenerator<?> getKeyGenerator(); /** * @return implementations bound to the repository instance (including the ones derived from the * {@link TypeMappingContext} used when instantiating the repository. */ List<Class<?>> getBoundImplementations(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultAdapter.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultAdapter.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.Invocation; /** * This interface is used to encapsulate the process of adapting results from a data store operation * to that of the invoked repository method. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/24/15) */ public interface ResultAdapter<E> extends Comparable<ResultAdapter> { /** * Called to determine whether or not this adapter can adapt the original value passed down from a * data store operation to the type required by the repository method being invoked * * @param invocation the invocation * @param originalValue the original value * @return {@literal true} if the adapter can convert the value */ boolean accepts(Invocation invocation, Object originalValue); /** * Called when we need to adapt the result from an invocation to the result required by the * repository method * * @param invocation the repository method invocation * @param originalValue the original value returned from a data store operation * @return the adapted value */ E adapt(Invocation invocation, Object originalValue); /** @return the priority for this adapter */ int getPriority(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/DependencyAware.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/DependencyAware.java
package com.mmnaseri.utils.spring.data.proxy; /** * This interface indicates that an interface should be used to inject dependencies into a concrete * mapping implementation class. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (4/14/16, 12:49 AM) */ @SuppressWarnings("WeakerAccess") public interface DependencyAware {}
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultAdapterContext.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/ResultAdapterContext.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.domain.Invocation; import java.util.Collection; /** * This interface is used to register result adapters and later call on them to adapt the results to * the appropriate type. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/24/15) */ public interface ResultAdapterContext { /** * Registers a new result adapter with this context * * @param adapter the adapter */ void register(ResultAdapter<?> adapter); /** * Will call the registered result adapters to adapt the results to the required type. * * @param invocation the invocation for which we are adapting the results * @param originalResult the original result from the data store operation * @return the adapted result */ Object adapt(Invocation invocation, Object originalResult); /** @return all the adapters registered with this context */ Collection<ResultAdapter<?>> getAdapters(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/InvocationMapping.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/InvocationMapping.java
package com.mmnaseri.utils.spring.data.proxy; import com.mmnaseri.utils.spring.data.store.DataStoreOperation; import java.lang.reflect.Method; /** * This interface is used to represent data about a single invocation mapping, consisting of the * method and the data store operation to which it is bound. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public interface InvocationMapping<K, E> { /** @return the method */ Method getMethod(); /** @return the data store operation */ DataStoreOperation<?, K, E> getOperation(); }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false
mmnaseri/spring-data-mock
https://github.com/mmnaseri/spring-data-mock/blob/e8547729050c9454872a1038c23bb9b1288c8654/spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/impl/ImmutableTypeMapping.java
spring-data-mock/src/main/java/com/mmnaseri/utils/spring/data/proxy/impl/ImmutableTypeMapping.java
package com.mmnaseri.utils.spring.data.proxy.impl; import com.mmnaseri.utils.spring.data.proxy.TypeMapping; /** * This is an immutable type mapping. * * @author Milad Naseri (m.m.naseri@gmail.com) * @since 1.0 (9/29/15) */ public class ImmutableTypeMapping<E> implements TypeMapping<E> { private final Class<E> type; private final E instance; public ImmutableTypeMapping(Class<E> type, E instance) { this.type = type; this.instance = instance; } @Override public Class<E> getType() { return type; } @Override public E getInstance() { return instance; } }
java
MIT
e8547729050c9454872a1038c23bb9b1288c8654
2026-01-05T02:41:15.897176Z
false