Skip to content

Commit

Permalink
Eliminate mysema.lang dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
velo committed Aug 30, 2024
1 parent 71b091d commit 3e8eb79
Show file tree
Hide file tree
Showing 54 changed files with 157 additions and 93 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
</distributionManagement>

<properties>
<japicmp.skip>true</japicmp.skip>

<failIfNoTests>false</failIfNoTests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.homepage>http://www.querydsl.com</project.homepage>
Expand Down Expand Up @@ -134,7 +136,6 @@
<mvn.version>3.9.9</mvn.version>
<guava.version>33.3.0-jre</guava.version>
<codegen.version>0.6.8</codegen.version>
<mysema.lang.version>0.2.4</mysema.lang.version>
<byte-buddy.version>1.15.0</byte-buddy.version>
<slf4j.version>2.0.16</slf4j.version>
<surefire.version>3.4.0</surefire.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
package com.querydsl.collections;

import com.mysema.commons.lang.CloseableIterator;
import com.mysema.commons.lang.IteratorAdapter;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.FetchableQuery;
import com.querydsl.core.JoinType;
import com.querydsl.core.NonUniqueResultException;
Expand Down Expand Up @@ -180,7 +179,7 @@ public <P> Q leftJoin(MapExpression<?, P> target, Path<P> alias) {
public CloseableIterator<T> iterate() {
@SuppressWarnings("unchecked") // This is the built type
var projection = (Expression<T>) queryMixin.getMetadata().getProjection();
return new IteratorAdapter<>(fetch().iterator());
return CloseableIterator.of(fetch().iterator());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
package com.querydsl.collections;

import com.mysema.commons.lang.IteratorAdapter;
import com.querydsl.codegen.utils.Evaluator;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.JoinExpression;
import com.querydsl.core.JoinType;
import com.querydsl.core.QueryMetadata;
Expand Down Expand Up @@ -166,7 +166,7 @@ private List evaluateSingleSource(
if (iterable instanceof List<?> list1) {
list = list1;
} else {
list = IteratorAdapter.asList(iterable.iterator());
list = CloseableIterator.asList(iterable.iterator());
}

// from & where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;

import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.FetchableQuery;
import com.querydsl.core.ResultTransformer;
import com.querydsl.core.annotations.QueryEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import com.mysema.commons.lang.IteratorAdapter;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.QueryModifiers;
import com.querydsl.core.QueryResults;
import com.querydsl.core.types.dsl.Expressions;
Expand Down Expand Up @@ -55,7 +55,8 @@ private void assertResultSize(int total, int size, QueryModifiers modifiers) {
assertThat(createQuery(modifiers).fetchCount()).isEqualTo(total);

// via iterator
assertThat(IteratorAdapter.asList(createQuery(modifiers).select(var).iterate())).hasSize(size);
assertThat(CloseableIterator.asList(createQuery(modifiers).select(var).iterate()))
.hasSize(size);
}

private CollQuery<?> createQuery(QueryModifiers modifiers) {
Expand Down
5 changes: 0 additions & 5 deletions querydsl-libraries/querydsl-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
<artifactId>annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mysema.commons</groupId>
<artifactId>mysema-commons-lang</artifactId>
<version>${mysema.lang.version}</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.querydsl.core;

import java.util.Iterator;
import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

public interface CloseableIterator<T> extends Iterator<T>, AutoCloseable {

@Override
void close();

public static <E> List<E> asList(CloseableIterator<E> iterator) {
try (iterator) {
return StreamSupport.stream(
Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false)
.collect(Collectors.toList());
}
}

public static <E> CloseableIterator<E> of(Iterator<E> iterator) {
return of(iterator, () -> {});
}

public static <E> CloseableIterator<E> of(CloseableIterator<E> iterator) {
return of(iterator, iterator);
}

public static <E> CloseableIterator<E> of(Iterator<E> iterator, AutoCloseable closeable) {
return new CloseableIterator<E>() {

@Override
public boolean hasNext() {
return iterator.hasNext();
}

@Override
public E next() {
return iterator.next();
}

@Override
public void close() {
try {
closeable.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
}

public static <E> List<E> asList(Iterator<E> iterator) {
return asList(of(iterator));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.querydsl.core;

import com.mysema.commons.lang.CloseableIterator;
import java.util.List;
import java.util.Spliterator;
import java.util.Spliterators;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.querydsl.core;

public record Pair<F, S>(F first, S second) {

@Deprecated
public F getFirst() {
return first();
}

@Deprecated
public S getSecond() {
return second();
}

public static <T, U> Pair<T, U> of(T key, U value) {
return new Pair<>(key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.querydsl.core.group;

import com.mysema.commons.lang.Pair;
import com.querydsl.core.Pair;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.querydsl.core.group;

import com.mysema.commons.lang.Pair;
import com.querydsl.core.Pair;
import com.querydsl.core.ResultTransformer;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Projections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.querydsl.core.group;

import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.ResultTransformer;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.FactoryExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static com.querydsl.core.util.TupleUtils.toTuple;

import com.mysema.commons.lang.CloseableIterator;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.FetchableQuery;
import com.querydsl.core.Tuple;
import com.querydsl.core.types.Expression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
package com.querydsl.core.group;

import com.mysema.commons.lang.Pair;
import com.querydsl.core.Pair;
import com.querydsl.core.types.ConstructorExpression;
import com.querydsl.core.types.Expression;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
package com.querydsl.core.support;

import com.mysema.commons.lang.CloseableIterator;
import com.mysema.commons.lang.IteratorAdapter;
import com.querydsl.core.CloseableIterator;
import com.querydsl.core.Fetchable;
import com.querydsl.core.FetchableQuery;
import com.querydsl.core.NonUniqueResultException;
Expand All @@ -40,7 +39,7 @@ public FetchableQueryBase(QueryMixin<Q> queryMixin) {

@Override
public List<T> fetch() {
return IteratorAdapter.asList(iterate());
return CloseableIterator.asList(iterate());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.querydsl.core.group;

import com.mysema.commons.lang.Pair;
import com.querydsl.core.Pair;
import com.querydsl.core.Tuple;
import com.querydsl.core.support.DummyFetchableQuery;
import com.querydsl.core.types.ConstructorExpression;
Expand Down
Loading

0 comments on commit 3e8eb79

Please sign in to comment.