repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
caligin/tinytypes | meta/src/test/java/tech/anima/tinytypes/meta/IntTinyTypesTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
| import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class IntTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsIntTT() { | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
// Path: meta/src/test/java/tech/anima/tinytypes/meta/IntTinyTypesTest.java
import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class IntTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsIntTT() { | final boolean got = new IntTinyTypes().isMetaOf(Samples.Integer.class); |
caligin/tinytypes | jersey/src/test/java/tech/anima/tinytypes/jersey/TinyTypesHeaderDelegateProviderTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
| import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.jersey;
@RunWith(Enclosed.class)
public class TinyTypesHeaderDelegateProviderTest {
@RunWith(Theories.class)
public static class Ctor {
@DataPoints
public static final Class<?>[] tinyTypesSamples = new Class<?>[]{ | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
// Path: jersey/src/test/java/tech/anima/tinytypes/jersey/TinyTypesHeaderDelegateProviderTest.java
import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.jersey;
@RunWith(Enclosed.class)
public class TinyTypesHeaderDelegateProviderTest {
@RunWith(Theories.class)
public static class Ctor {
@DataPoints
public static final Class<?>[] tinyTypesSamples = new Class<?>[]{ | Samples.Str.class, |
caligin/tinytypes | meta/src/test/java/tech/anima/tinytypes/meta/ShortTinyTypesTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
//
// Path: testing/src/main/java/tech/anima/tinytypes/Samples.java
// public static class ShortIndirectAncestor extends Samples.Short {
//
// public ShortIndirectAncestor(short value) {
// super(value);
// }
// }
| import tech.anima.tinytypes.Samples;
import tech.anima.tinytypes.Samples.ShortIndirectAncestor;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class ShortTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsShortTT() { | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
//
// Path: testing/src/main/java/tech/anima/tinytypes/Samples.java
// public static class ShortIndirectAncestor extends Samples.Short {
//
// public ShortIndirectAncestor(short value) {
// super(value);
// }
// }
// Path: meta/src/test/java/tech/anima/tinytypes/meta/ShortTinyTypesTest.java
import tech.anima.tinytypes.Samples;
import tech.anima.tinytypes.Samples.ShortIndirectAncestor;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class ShortTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsShortTT() { | final boolean got = new ShortTinyTypes().isMetaOf(Samples.Short.class); |
caligin/tinytypes | meta/src/test/java/tech/anima/tinytypes/meta/ShortTinyTypesTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
//
// Path: testing/src/main/java/tech/anima/tinytypes/Samples.java
// public static class ShortIndirectAncestor extends Samples.Short {
//
// public ShortIndirectAncestor(short value) {
// super(value);
// }
// }
| import tech.anima.tinytypes.Samples;
import tech.anima.tinytypes.Samples.ShortIndirectAncestor;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class ShortTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsShortTT() {
final boolean got = new ShortTinyTypes().isMetaOf(Samples.Short.class);
Assert.assertTrue(got);
}
@Test
public void yieldsFalseWhenCandidateSuperclassIsNotShortTT() {
final boolean got = new ShortTinyTypes().isMetaOf(Samples.class);
Assert.assertFalse(got);
}
@Test
public void yieldsFalseWhenAncestorOfCandidateIsShortTTButNotDirectSuperclass() { | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
//
// Path: testing/src/main/java/tech/anima/tinytypes/Samples.java
// public static class ShortIndirectAncestor extends Samples.Short {
//
// public ShortIndirectAncestor(short value) {
// super(value);
// }
// }
// Path: meta/src/test/java/tech/anima/tinytypes/meta/ShortTinyTypesTest.java
import tech.anima.tinytypes.Samples;
import tech.anima.tinytypes.Samples.ShortIndirectAncestor;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class ShortTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsShortTT() {
final boolean got = new ShortTinyTypes().isMetaOf(Samples.Short.class);
Assert.assertTrue(got);
}
@Test
public void yieldsFalseWhenCandidateSuperclassIsNotShortTT() {
final boolean got = new ShortTinyTypes().isMetaOf(Samples.class);
Assert.assertFalse(got);
}
@Test
public void yieldsFalseWhenAncestorOfCandidateIsShortTTButNotDirectSuperclass() { | final boolean got = new ShortTinyTypes().isMetaOf(ShortIndirectAncestor.class); |
caligin/tinytypes | meta/src/test/java/tech/anima/tinytypes/meta/StringTinyTypesTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
| import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class StringTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsStringTT() { | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
// Path: meta/src/test/java/tech/anima/tinytypes/meta/StringTinyTypesTest.java
import tech.anima.tinytypes.Samples;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.meta;
@RunWith(Enclosed.class)
public class StringTinyTypesTest {
public static class IsMetaOf {
@Test
public void yieldsTrueWhenCandidateSuperclassIsStringTT() { | final boolean got = new StringTinyTypes().isMetaOf(Samples.Str.class); |
caligin/tinytypes | jackson/src/main/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializers.java | // Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyType.java
// public interface MetaTinyType<T> {
//
// /**
// * Checks whether this implementation can operate on the given TinyType
// * class type.
// *
// * @param candidate the TInyType type to check for compatibility
// * @return true if the candidate is supported, false otherwise
// */
// boolean isMetaOf(Class<?> candidate);
//
// /**
// * Returns a String representation of the value wrapped in the given
// * TinyType. The given TinyType must be compatible with this meta.
// *
// * @param value the TinyType to stringify
// * @return a String representation of the native value wrapped in the
// * TinyType
// */
// String stringify(T value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value. The given TinyType class type and the type of value must
// * both be compatible with this meta.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U newInstance(Class<U> type, Object value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value given in string form. The given TinyType class type must be
// * compatible with this meta, the given String value must be parseable as
// * the appropriate native type.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U fromString(Class<U> type, String value);
// }
//
// Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java
// public abstract class MetaTinyTypes {
//
// public static final MetaTinyType[] metas = new MetaTinyType[]{
// new StringTinyTypes(),
// new BooleanTinyTypes(),
// new ByteTinyTypes(),
// new ShortTinyTypes(),
// new IntTinyTypes(),
// new LongTinyTypes()
// };
//
// /**
// * Provides a type-specific Meta class for the given TinyType.
// *
// * @param <T> the TinyType class type
// * @param candidate the TinyType class to obtain a Meta for
// * @return a Meta implementation suitable for the candidate
// * @throws IllegalArgumentException for null or a non-TinyType
// */
// public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return meta;
// }
// }
// throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
// }
//
// /**
// * Checks whether a class is a TinyType. A class is considered a TinyType if
// * is a direct ancestor of a tech.anima.tinytypes.*TinyType, is not abstract
// * and provides a ctor matching super.
// *
// * @param candidate the class to be checked
// * @return true if the candidate is a TinyType, false otherwise.
// */
// public static boolean isTinyType(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return true;
// }
// }
// return false;
// }
//
// }
| import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.Serializers;
import java.io.IOException;
import tech.anima.tinytypes.meta.MetaTinyType;
import tech.anima.tinytypes.meta.MetaTinyTypes; | package tech.anima.tinytypes.jackson;
public class TinyTypesKeySerializers extends Serializers.Base {
@Override
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
Class<?> candidateTT = type.getRawClass(); | // Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyType.java
// public interface MetaTinyType<T> {
//
// /**
// * Checks whether this implementation can operate on the given TinyType
// * class type.
// *
// * @param candidate the TInyType type to check for compatibility
// * @return true if the candidate is supported, false otherwise
// */
// boolean isMetaOf(Class<?> candidate);
//
// /**
// * Returns a String representation of the value wrapped in the given
// * TinyType. The given TinyType must be compatible with this meta.
// *
// * @param value the TinyType to stringify
// * @return a String representation of the native value wrapped in the
// * TinyType
// */
// String stringify(T value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value. The given TinyType class type and the type of value must
// * both be compatible with this meta.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U newInstance(Class<U> type, Object value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value given in string form. The given TinyType class type must be
// * compatible with this meta, the given String value must be parseable as
// * the appropriate native type.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U fromString(Class<U> type, String value);
// }
//
// Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java
// public abstract class MetaTinyTypes {
//
// public static final MetaTinyType[] metas = new MetaTinyType[]{
// new StringTinyTypes(),
// new BooleanTinyTypes(),
// new ByteTinyTypes(),
// new ShortTinyTypes(),
// new IntTinyTypes(),
// new LongTinyTypes()
// };
//
// /**
// * Provides a type-specific Meta class for the given TinyType.
// *
// * @param <T> the TinyType class type
// * @param candidate the TinyType class to obtain a Meta for
// * @return a Meta implementation suitable for the candidate
// * @throws IllegalArgumentException for null or a non-TinyType
// */
// public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return meta;
// }
// }
// throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
// }
//
// /**
// * Checks whether a class is a TinyType. A class is considered a TinyType if
// * is a direct ancestor of a tech.anima.tinytypes.*TinyType, is not abstract
// * and provides a ctor matching super.
// *
// * @param candidate the class to be checked
// * @return true if the candidate is a TinyType, false otherwise.
// */
// public static boolean isTinyType(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return true;
// }
// }
// return false;
// }
//
// }
// Path: jackson/src/main/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializers.java
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.Serializers;
import java.io.IOException;
import tech.anima.tinytypes.meta.MetaTinyType;
import tech.anima.tinytypes.meta.MetaTinyTypes;
package tech.anima.tinytypes.jackson;
public class TinyTypesKeySerializers extends Serializers.Base {
@Override
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
Class<?> candidateTT = type.getRawClass(); | if (MetaTinyTypes.isTinyType(candidateTT)) { |
caligin/tinytypes | jackson/src/main/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializers.java | // Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyType.java
// public interface MetaTinyType<T> {
//
// /**
// * Checks whether this implementation can operate on the given TinyType
// * class type.
// *
// * @param candidate the TInyType type to check for compatibility
// * @return true if the candidate is supported, false otherwise
// */
// boolean isMetaOf(Class<?> candidate);
//
// /**
// * Returns a String representation of the value wrapped in the given
// * TinyType. The given TinyType must be compatible with this meta.
// *
// * @param value the TinyType to stringify
// * @return a String representation of the native value wrapped in the
// * TinyType
// */
// String stringify(T value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value. The given TinyType class type and the type of value must
// * both be compatible with this meta.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U newInstance(Class<U> type, Object value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value given in string form. The given TinyType class type must be
// * compatible with this meta, the given String value must be parseable as
// * the appropriate native type.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U fromString(Class<U> type, String value);
// }
//
// Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java
// public abstract class MetaTinyTypes {
//
// public static final MetaTinyType[] metas = new MetaTinyType[]{
// new StringTinyTypes(),
// new BooleanTinyTypes(),
// new ByteTinyTypes(),
// new ShortTinyTypes(),
// new IntTinyTypes(),
// new LongTinyTypes()
// };
//
// /**
// * Provides a type-specific Meta class for the given TinyType.
// *
// * @param <T> the TinyType class type
// * @param candidate the TinyType class to obtain a Meta for
// * @return a Meta implementation suitable for the candidate
// * @throws IllegalArgumentException for null or a non-TinyType
// */
// public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return meta;
// }
// }
// throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
// }
//
// /**
// * Checks whether a class is a TinyType. A class is considered a TinyType if
// * is a direct ancestor of a tech.anima.tinytypes.*TinyType, is not abstract
// * and provides a ctor matching super.
// *
// * @param candidate the class to be checked
// * @return true if the candidate is a TinyType, false otherwise.
// */
// public static boolean isTinyType(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return true;
// }
// }
// return false;
// }
//
// }
| import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.Serializers;
import java.io.IOException;
import tech.anima.tinytypes.meta.MetaTinyType;
import tech.anima.tinytypes.meta.MetaTinyTypes; | package tech.anima.tinytypes.jackson;
public class TinyTypesKeySerializers extends Serializers.Base {
@Override
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
Class<?> candidateTT = type.getRawClass();
if (MetaTinyTypes.isTinyType(candidateTT)) {
return new TinyTypesKeySerializer<>(candidateTT);
}
return super.findSerializer(config, type, beanDesc);
}
public static class TinyTypesKeySerializer<T> extends JsonSerializer<T> {
| // Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyType.java
// public interface MetaTinyType<T> {
//
// /**
// * Checks whether this implementation can operate on the given TinyType
// * class type.
// *
// * @param candidate the TInyType type to check for compatibility
// * @return true if the candidate is supported, false otherwise
// */
// boolean isMetaOf(Class<?> candidate);
//
// /**
// * Returns a String representation of the value wrapped in the given
// * TinyType. The given TinyType must be compatible with this meta.
// *
// * @param value the TinyType to stringify
// * @return a String representation of the native value wrapped in the
// * TinyType
// */
// String stringify(T value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value. The given TinyType class type and the type of value must
// * both be compatible with this meta.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U newInstance(Class<U> type, Object value);
//
// /**
// * Creates a new instance of the given TinyType class type, wrapping the
// * given value given in string form. The given TinyType class type must be
// * compatible with this meta, the given String value must be parseable as
// * the appropriate native type.
// *
// * @param <U> the TinyType class type to construct
// * @param type the TinyType class type to construct
// * @param value the native value to wrap
// * @return a new instance of U wrapping the given value
// */
// <U extends T> U fromString(Class<U> type, String value);
// }
//
// Path: meta/src/main/java/tech/anima/tinytypes/meta/MetaTinyTypes.java
// public abstract class MetaTinyTypes {
//
// public static final MetaTinyType[] metas = new MetaTinyType[]{
// new StringTinyTypes(),
// new BooleanTinyTypes(),
// new ByteTinyTypes(),
// new ShortTinyTypes(),
// new IntTinyTypes(),
// new LongTinyTypes()
// };
//
// /**
// * Provides a type-specific Meta class for the given TinyType.
// *
// * @param <T> the TinyType class type
// * @param candidate the TinyType class to obtain a Meta for
// * @return a Meta implementation suitable for the candidate
// * @throws IllegalArgumentException for null or a non-TinyType
// */
// public static <T> MetaTinyType<T> metaFor(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return meta;
// }
// }
// throw new IllegalArgumentException(String.format("not a tinytype: %s", candidate == null ? "null" : candidate.getCanonicalName()));
// }
//
// /**
// * Checks whether a class is a TinyType. A class is considered a TinyType if
// * is a direct ancestor of a tech.anima.tinytypes.*TinyType, is not abstract
// * and provides a ctor matching super.
// *
// * @param candidate the class to be checked
// * @return true if the candidate is a TinyType, false otherwise.
// */
// public static boolean isTinyType(Class<?> candidate) {
// for (MetaTinyType meta : metas) {
// if (meta.isMetaOf(candidate)) {
// return true;
// }
// }
// return false;
// }
//
// }
// Path: jackson/src/main/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializers.java
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.Serializers;
import java.io.IOException;
import tech.anima.tinytypes.meta.MetaTinyType;
import tech.anima.tinytypes.meta.MetaTinyTypes;
package tech.anima.tinytypes.jackson;
public class TinyTypesKeySerializers extends Serializers.Base {
@Override
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
Class<?> candidateTT = type.getRawClass();
if (MetaTinyTypes.isTinyType(candidateTT)) {
return new TinyTypesKeySerializer<>(candidateTT);
}
return super.findSerializer(config, type, beanDesc);
}
public static class TinyTypesKeySerializer<T> extends JsonSerializer<T> {
| private final MetaTinyType<T> meta; |
caligin/tinytypes | jackson/src/test/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializersTest.java | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
| import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import tech.anima.tinytypes.Samples;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith; | package tech.anima.tinytypes.jackson;
@RunWith(Enclosed.class)
public class TinyTypesKeySerializersTest {
@RunWith(Theories.class)
public static class FindKeySerializer {
@Test
public void delegatesToOtherWhenTypeIsNotATinyType() throws JsonMappingException {
final JavaType typeForObject = TypeFactory.defaultInstance().uncheckedSimpleType(Object.class);
final JsonSerializer<?> got = new TinyTypesKeySerializers().findSerializer(null, typeForObject, null);
Assert.assertFalse(got instanceof TinyTypesKeySerializers.TinyTypesKeySerializer);
}
@DataPoints
public static final Class<?>[] tinyTypesSamples = new Class<?>[]{ | // Path: tinytypes/src/test/java/tech/anima/tinytypes/Samples.java
// public class Samples {
//
// public static class Integer extends IntTinyType {
//
// public Integer(int value) {
// super(value);
// }
//
// public static Integer of(int value) {
// return new Integer(value);
// }
//
// }
//
// public static class OtherInteger extends IntTinyType {
//
// public OtherInteger(int value) {
// super(value);
// }
//
// public static OtherInteger of(int value) {
// return new OtherInteger(value);
// }
//
// }
//
// public static class Byte extends ByteTinyType {
//
// public Byte(byte value) {
// super(value);
// }
//
// public static Byte of(byte value) {
// return new Byte(value);
// }
//
// }
//
// public static class OtherByte extends ByteTinyType {
//
// public OtherByte(byte value) {
// super(value);
// }
//
// public static OtherByte of(byte value) {
// return new OtherByte(value);
// }
//
// }
//
// public static class Str extends StringTinyType {
//
// public Str(String value) {
// super(value);
// }
//
// public static Str of(String value) {
// return new Str(value);
// }
//
// }
//
// public static class OtherStr extends StringTinyType {
//
// public OtherStr(String value) {
// super(value);
// }
//
// public static OtherStr of(String value) {
// return new OtherStr(value);
// }
//
// }
//
// public static class Boolean extends BooleanTinyType {
//
// public Boolean(boolean value) {
// super(value);
// }
//
// public static Boolean of(boolean value) {
// return new Boolean(value);
// }
//
// }
//
// public static class OtherBoolean extends BooleanTinyType {
//
// public OtherBoolean(boolean value) {
// super(value);
// }
//
// public static OtherBoolean of(boolean value) {
// return new OtherBoolean(value);
// }
//
// }
//
// public static class Long extends LongTinyType {
//
// public Long(long value) {
// super(value);
// }
//
// public static Long of(long value) {
// return new Long(value);
// }
//
// }
//
// public static class OtherLong extends LongTinyType {
//
// public OtherLong(long value) {
// super(value);
// }
//
// public static OtherLong of(long value) {
// return new OtherLong(value);
// }
//
// }
//
// public static class Short extends ShortTinyType {
//
// public Short(short value) {
// super(value);
// }
//
// public static Short of(short value) {
// return new Short(value);
// }
//
// }
//
// public static class OtherShort extends ShortTinyType {
//
// public OtherShort(short value) {
// super(value);
// }
//
// public static OtherShort of(short value) {
// return new OtherShort(value);
// }
//
// }
//
// }
// Path: jackson/src/test/java/tech/anima/tinytypes/jackson/TinyTypesKeySerializersTest.java
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import tech.anima.tinytypes.Samples;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import org.junit.Test;
import org.junit.Assert;
import org.junit.experimental.runners.Enclosed;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
package tech.anima.tinytypes.jackson;
@RunWith(Enclosed.class)
public class TinyTypesKeySerializersTest {
@RunWith(Theories.class)
public static class FindKeySerializer {
@Test
public void delegatesToOtherWhenTypeIsNotATinyType() throws JsonMappingException {
final JavaType typeForObject = TypeFactory.defaultInstance().uncheckedSimpleType(Object.class);
final JsonSerializer<?> got = new TinyTypesKeySerializers().findSerializer(null, typeForObject, null);
Assert.assertFalse(got instanceof TinyTypesKeySerializers.TinyTypesKeySerializer);
}
@DataPoints
public static final Class<?>[] tinyTypesSamples = new Class<?>[]{ | Samples.Str.class, |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceConstants.java | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.ui";
//
// /**
// * The shared instance.
// */
// private static Activator plugin;
//
// /**
// * The constructor.
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
| import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.ui.Activator; | public static final String GENERATION_JAVA_2_SOLIDITY_TYPES = "GENERATION_JAVA_2_SOLIDITY_TYPES";
public static final String GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX = "GENERATION_JAVA_2_SOLIDITY_TYPE_";
public static final String GENERATE_JAVA_TESTS = "GENERATE_JAVA_TESTS";
public static final String GENERATION_JAVA_TEST_TARGET = "GENERATION_JAVA_TEST_TARGET";
public static final String GENERATE_WEB3 = "GENERATE_WEB3";
public static final String GENERATE_HTML = "GENERATE_HTML";
public static final String GENERATE_MIX = "GENERATE_MIX";
public static final String GENERATE_MARKDOWN = "GENERATE_MARKDOWN";
public static final String JS_FILE_HEADER = "JS_FILE_HEADER";
public static final String GENERATE_JS_CONTROLLER = "GENERATE_JS_CONTROLLER";
public static final String GENERATE_JS_CONTROLLER_TARGET = "GENERATE_JS_CONTROLLER_TARGET";
public static final String GENERATE_JS_TEST = "GENERATE_JS_TEST";
public static final String GENERATE_JS_TEST_TARGET = "GENERATE_JS_TEST_TARGET";
public static final String GENERATE_ABI_TARGET = "GENERATE_ABI_TARGET";
public static final String GENERATE_ABI = "GENERATE_ABI";
public static final String GENERATOR_PROJECT_SETTINGS = "COMPILE_CONTRACTS_PROJECT_SETTINGS";
public static final String CONTRACT_FILE_HEADER = "CONTRACT_FILE_HEADER";
public static final String VERSION_PRAGMA = "version_pragma";
public static final String ENABLE_VERSION = "enable_version";
public static final String GENERATE_JAVA_NONBLOCKING = "GENERATE_JAVA_NONBLOCKING";
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) { | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.ui";
//
// /**
// * The shared instance.
// */
// private static Activator plugin;
//
// /**
// * The constructor.
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceConstants.java
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.ui.Activator;
public static final String GENERATION_JAVA_2_SOLIDITY_TYPES = "GENERATION_JAVA_2_SOLIDITY_TYPES";
public static final String GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX = "GENERATION_JAVA_2_SOLIDITY_TYPE_";
public static final String GENERATE_JAVA_TESTS = "GENERATE_JAVA_TESTS";
public static final String GENERATION_JAVA_TEST_TARGET = "GENERATION_JAVA_TEST_TARGET";
public static final String GENERATE_WEB3 = "GENERATE_WEB3";
public static final String GENERATE_HTML = "GENERATE_HTML";
public static final String GENERATE_MIX = "GENERATE_MIX";
public static final String GENERATE_MARKDOWN = "GENERATE_MARKDOWN";
public static final String JS_FILE_HEADER = "JS_FILE_HEADER";
public static final String GENERATE_JS_CONTROLLER = "GENERATE_JS_CONTROLLER";
public static final String GENERATE_JS_CONTROLLER_TARGET = "GENERATE_JS_CONTROLLER_TARGET";
public static final String GENERATE_JS_TEST = "GENERATE_JS_TEST";
public static final String GENERATE_JS_TEST_TARGET = "GENERATE_JS_TEST_TARGET";
public static final String GENERATE_ABI_TARGET = "GENERATE_ABI_TARGET";
public static final String GENERATE_ABI = "GENERATE_ABI";
public static final String GENERATOR_PROJECT_SETTINGS = "COMPILE_CONTRACTS_PROJECT_SETTINGS";
public static final String CONTRACT_FILE_HEADER = "CONTRACT_FILE_HEADER";
public static final String VERSION_PRAGMA = "version_pragma";
public static final String ENABLE_VERSION = "enable_version";
public static final String GENERATE_JAVA_NONBLOCKING = "GENERATE_JAVA_NONBLOCKING";
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) { | IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID); |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcBuilderPreferencePage.java | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
//
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java
// public static class SolC{
// String name;
// String path;
// String version;
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((path == null) ? 0 : path.hashCode());
// result = prime * result + ((version == null) ? 0 : version.hashCode());
// return result;
// }
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SolC other = (SolC) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (path == null) {
// if (other.path != null)
// return false;
// } else if (!path.equals(other.path))
// return false;
// if (version == null) {
// if (other.version != null)
// return false;
// } else if (!version.equals(other.version))
// return false;
// return true;
// }
// }
| import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringButtonFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
import de.urszeidler.eclipse.solidity.compiler.support.preferences.PreferenceConstants.SolC; | getFieldEditorParent()) {
@Override
protected String changePressed() {
Path srcDir = new Path(getStringValue());
IResource member = project.findMember(srcDir);
if (member == null)
member = ResourcesPlugin.getWorkspace().getRoot().findMember(srcDir);
ContainerSelectionDialog containerSelectionDialog = new ContainerSelectionDialog(getShell(),
(IContainer) member, false, "select dirctory of the source files");
containerSelectionDialog.open();
Object[] result = containerSelectionDialog.getResult();
if (result != null && result.length == 1) {
IPath container = (IPath) result[0];
compilerTarget.setStringValue(container.toString() + "/combined.json");
return container.toString();
}
return null;
}
};
sourceDirectory.setEmptyStringAllowed(false);
addField(sourceDirectory);
}
compilerTarget = new StringFieldEditor(PreferenceConstants.COMPILER_TARGET_COMBINE_ABI, "compile to file", -1,
StringFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent());
addField(compilerTarget);
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, preferencesId()); | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
//
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java
// public static class SolC{
// String name;
// String path;
// String version;
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((path == null) ? 0 : path.hashCode());
// result = prime * result + ((version == null) ? 0 : version.hashCode());
// return result;
// }
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SolC other = (SolC) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (path == null) {
// if (other.path != null)
// return false;
// } else if (!path.equals(other.path))
// return false;
// if (version == null) {
// if (other.version != null)
// return false;
// } else if (!version.equals(other.version))
// return false;
// return true;
// }
// }
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcBuilderPreferencePage.java
import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringButtonFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
import de.urszeidler.eclipse.solidity.compiler.support.preferences.PreferenceConstants.SolC;
getFieldEditorParent()) {
@Override
protected String changePressed() {
Path srcDir = new Path(getStringValue());
IResource member = project.findMember(srcDir);
if (member == null)
member = ResourcesPlugin.getWorkspace().getRoot().findMember(srcDir);
ContainerSelectionDialog containerSelectionDialog = new ContainerSelectionDialog(getShell(),
(IContainer) member, false, "select dirctory of the source files");
containerSelectionDialog.open();
Object[] result = containerSelectionDialog.getResult();
if (result != null && result.length == 1) {
IPath container = (IPath) result[0];
compilerTarget.setStringValue(container.toString() + "/combined.json");
return container.toString();
}
return null;
}
};
sourceDirectory.setEmptyStringAllowed(false);
addField(sourceDirectory);
}
compilerTarget = new StringFieldEditor(PreferenceConstants.COMPILER_TARGET_COMBINE_ABI, "compile to file", -1,
StringFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent());
addField(compilerTarget);
IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, preferencesId()); | final List<SolC> parsePreferences = PreferenceConstants |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcBuilderPreferencePage.java | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
//
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java
// public static class SolC{
// String name;
// String path;
// String version;
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((path == null) ? 0 : path.hashCode());
// result = prime * result + ((version == null) ? 0 : version.hashCode());
// return result;
// }
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SolC other = (SolC) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (path == null) {
// if (other.path != null)
// return false;
// } else if (!path.equals(other.path))
// return false;
// if (version == null) {
// if (other.version != null)
// return false;
// } else if (!version.equals(other.version))
// return false;
// return true;
// }
// }
| import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringButtonFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
import de.urszeidler.eclipse.solidity.compiler.support.preferences.PreferenceConstants.SolC; | setDescription(
"The project solidity builder preferences. "
+ "The builder compiles to a combine json format. "
+ "All *.sol files of the source directory are selected. Add/remove the builder via configure project.");
}else
setDescription(
"The solidity builder preferences. "
+ "The builder compiles to a combine json format. When selected for a project. "
+ "All *.sol files of the source directory are selected. Add/remove the builder via configure project.");
super.createControl(parent);
}
@Override
protected void checkState() {
super.checkState();
validateInput();
}
/**
* Initialize the preference page.
*/
public void init(IWorkbench workbench) {
// Initialize the preference page
}
@Override
protected String preferencesId() { | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
//
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java
// public static class SolC{
// String name;
// String path;
// String version;
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// result = prime * result + ((path == null) ? 0 : path.hashCode());
// result = prime * result + ((version == null) ? 0 : version.hashCode());
// return result;
// }
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// SolC other = (SolC) obj;
// if (name == null) {
// if (other.name != null)
// return false;
// } else if (!name.equals(other.name))
// return false;
// if (path == null) {
// if (other.path != null)
// return false;
// } else if (!path.equals(other.path))
// return false;
// if (version == null) {
// if (other.version != null)
// return false;
// } else if (!version.equals(other.version))
// return false;
// return true;
// }
// }
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcBuilderPreferencePage.java
import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringButtonFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
import de.urszeidler.eclipse.solidity.compiler.support.preferences.PreferenceConstants.SolC;
setDescription(
"The project solidity builder preferences. "
+ "The builder compiles to a combine json format. "
+ "All *.sol files of the source directory are selected. Add/remove the builder via configure project.");
}else
setDescription(
"The solidity builder preferences. "
+ "The builder compiles to a combine json format. When selected for a project. "
+ "All *.sol files of the source directory are selected. Add/remove the builder via configure project.");
super.createControl(parent);
}
@Override
protected void checkState() {
super.checkState();
validateInput();
}
/**
* Initialize the preference page.
*/
public void init(IWorkbench workbench) {
// Initialize the preference page
}
@Override
protected String preferencesId() { | return Activator.PLUGIN_ID; |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/util/Uml2Service.java | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceConstants.java
// public class PreferenceConstants {
//
// public static final String GENERATE_CONTRACT_FILES = "GENERATE_CONTRACT_FILES";
// public static final String GENERATION_TARGET = "GENERATION_TARGET";
// public static final String GENERATION_TARGET_DOC = "GENERATION_TARGET_DOC";
// public static final String GENERATION_ALL_IN_ONE_FILE = "GENERATION_ALL_IN_ONE_FILE";
//
// public static final String GENERATE_JAVA_INTERFACE = "GENERATE_JAVA_INTERFACE";
// public static final String GENERATION_JAVA_INTERFACE_TARGET = "GENERATION_JAVA_INTERFACE_TARGET";
// public static final String GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX = "GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX";
// public static final String GENERATION_JAVA_2_SOLIDITY_TYPES = "GENERATION_JAVA_2_SOLIDITY_TYPES";
// public static final String GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX = "GENERATION_JAVA_2_SOLIDITY_TYPE_";
// public static final String GENERATE_JAVA_TESTS = "GENERATE_JAVA_TESTS";
// public static final String GENERATION_JAVA_TEST_TARGET = "GENERATION_JAVA_TEST_TARGET";
//
//
// public static final String GENERATE_WEB3 = "GENERATE_WEB3";
// public static final String GENERATE_HTML = "GENERATE_HTML";
// public static final String GENERATE_MIX = "GENERATE_MIX";
// public static final String GENERATE_MARKDOWN = "GENERATE_MARKDOWN";
//
// public static final String JS_FILE_HEADER = "JS_FILE_HEADER";
// public static final String GENERATE_JS_CONTROLLER = "GENERATE_JS_CONTROLLER";
// public static final String GENERATE_JS_CONTROLLER_TARGET = "GENERATE_JS_CONTROLLER_TARGET";
// public static final String GENERATE_JS_TEST = "GENERATE_JS_TEST";
// public static final String GENERATE_JS_TEST_TARGET = "GENERATE_JS_TEST_TARGET";
// public static final String GENERATE_ABI_TARGET = "GENERATE_ABI_TARGET";
// public static final String GENERATE_ABI = "GENERATE_ABI";
//
// public static final String GENERATOR_PROJECT_SETTINGS = "COMPILE_CONTRACTS_PROJECT_SETTINGS";
// public static final String CONTRACT_FILE_HEADER = "CONTRACT_FILE_HEADER";
//
// public static final String VERSION_PRAGMA = "version_pragma";
// public static final String ENABLE_VERSION = "enable_version";
// public static final String GENERATE_JAVA_NONBLOCKING = "GENERATE_JAVA_NONBLOCKING";
//
//
//
// public static IPreferenceStore getPreferenceStore(IProject project) {
// if (project != null) {
// IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID);
// if(store.getBoolean(PreferenceConstants.GENERATOR_PROJECT_SETTINGS))
// return store;
// }
// return new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);//Activator.PLUGIN_ID);
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Interface;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
import de.urszeidler.eclipse.solidity.ui.preferences.PreferenceConstants; | }
} catch (IllegalArgumentException e) {
}
}
return new ArrayList<Object>();
}
/**
* Get the index of the given {@link NamedElement} of its container.
*
* @param clazz
* @return
*/
public static int getIndexInContainer(Element clazz) {
EObject eContainer = clazz.eContainer();
EStructuralFeature eContainingFeature = clazz.eContainingFeature();
List<?> eGet = (List<?>) eContainer.eGet(eContainingFeature);
return eGet.indexOf(clazz);
}
/**
* Returns the header for a solidity file.
*
* @param an
* element
* @return
*/
public static String getSolidityFileHeader(NamedElement clazz) {
IPreferenceStore store = getStore(clazz); | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceConstants.java
// public class PreferenceConstants {
//
// public static final String GENERATE_CONTRACT_FILES = "GENERATE_CONTRACT_FILES";
// public static final String GENERATION_TARGET = "GENERATION_TARGET";
// public static final String GENERATION_TARGET_DOC = "GENERATION_TARGET_DOC";
// public static final String GENERATION_ALL_IN_ONE_FILE = "GENERATION_ALL_IN_ONE_FILE";
//
// public static final String GENERATE_JAVA_INTERFACE = "GENERATE_JAVA_INTERFACE";
// public static final String GENERATION_JAVA_INTERFACE_TARGET = "GENERATION_JAVA_INTERFACE_TARGET";
// public static final String GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX = "GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX";
// public static final String GENERATION_JAVA_2_SOLIDITY_TYPES = "GENERATION_JAVA_2_SOLIDITY_TYPES";
// public static final String GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX = "GENERATION_JAVA_2_SOLIDITY_TYPE_";
// public static final String GENERATE_JAVA_TESTS = "GENERATE_JAVA_TESTS";
// public static final String GENERATION_JAVA_TEST_TARGET = "GENERATION_JAVA_TEST_TARGET";
//
//
// public static final String GENERATE_WEB3 = "GENERATE_WEB3";
// public static final String GENERATE_HTML = "GENERATE_HTML";
// public static final String GENERATE_MIX = "GENERATE_MIX";
// public static final String GENERATE_MARKDOWN = "GENERATE_MARKDOWN";
//
// public static final String JS_FILE_HEADER = "JS_FILE_HEADER";
// public static final String GENERATE_JS_CONTROLLER = "GENERATE_JS_CONTROLLER";
// public static final String GENERATE_JS_CONTROLLER_TARGET = "GENERATE_JS_CONTROLLER_TARGET";
// public static final String GENERATE_JS_TEST = "GENERATE_JS_TEST";
// public static final String GENERATE_JS_TEST_TARGET = "GENERATE_JS_TEST_TARGET";
// public static final String GENERATE_ABI_TARGET = "GENERATE_ABI_TARGET";
// public static final String GENERATE_ABI = "GENERATE_ABI";
//
// public static final String GENERATOR_PROJECT_SETTINGS = "COMPILE_CONTRACTS_PROJECT_SETTINGS";
// public static final String CONTRACT_FILE_HEADER = "CONTRACT_FILE_HEADER";
//
// public static final String VERSION_PRAGMA = "version_pragma";
// public static final String ENABLE_VERSION = "enable_version";
// public static final String GENERATE_JAVA_NONBLOCKING = "GENERATE_JAVA_NONBLOCKING";
//
//
//
// public static IPreferenceStore getPreferenceStore(IProject project) {
// if (project != null) {
// IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID);
// if(store.getBoolean(PreferenceConstants.GENERATOR_PROJECT_SETTINGS))
// return store;
// }
// return new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);//Activator.PLUGIN_ID);
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/util/Uml2Service.java
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Interface;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.Type;
import de.urszeidler.eclipse.solidity.ui.preferences.PreferenceConstants;
}
} catch (IllegalArgumentException e) {
}
}
return new ArrayList<Object>();
}
/**
* Get the index of the given {@link NamedElement} of its container.
*
* @param clazz
* @return
*/
public static int getIndexInContainer(Element clazz) {
EObject eContainer = clazz.eContainer();
EStructuralFeature eContainingFeature = clazz.eContainingFeature();
List<?> eGet = (List<?>) eContainer.eGet(eContainingFeature);
return eGet.indexOf(clazz);
}
/**
* Returns the header for a solidity file.
*
* @param an
* element
* @return
*/
public static String getSolidityFileHeader(NamedElement clazz) {
IPreferenceStore store = getStore(clazz); | return store.getString(PreferenceConstants.CONTRACT_FILE_HEADER); |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcCompilerPreferencePage.java | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
| import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import de.urszeidler.eclipse.solidity.compiler.support.Activator; | addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_ASM, "generate asm", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_ASM_JSON, "generate asm json", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_AST, "generate ast", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_AST_JSON, "generate ast json", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_USERDOC, "generate user doc", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_DEVDOC, "generate dev doc", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_OPCODE, "generate optcode", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_FORMAL, "generate formal", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_HASHES, "generate hashes", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
}
/**
* Initialize the preference page.
*/
public void init(IWorkbench workbench) {
// Initialize the preference page
}
@Override
protected String preferencesId() { | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/SolcCompilerPreferencePage.java
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_ASM, "generate asm", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_ASM_JSON, "generate asm json", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_AST, "generate ast", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_AST_JSON, "generate ast json", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_USERDOC, "generate user doc", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_DEVDOC, "generate dev doc", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_OPCODE, "generate optcode", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_FORMAL, "generate formal", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceConstants.COMPILER_HASHES, "generate hashes", BooleanFieldEditor.DEFAULT,
getFieldEditorParent()));
}
/**
* Initialize the preference page.
*/
public void init(IWorkbench workbench) {
// Initialize the preference page
}
@Override
protected String preferencesId() { | return Activator.PLUGIN_ID; |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator; | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SolC other = (SolC) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (path == null) {
if (other.path != null)
return false;
} else if (!path.equals(other.path))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
}
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) { | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.compiler.support"; //$NON-NLS-1$
//
// // The shared instance
// private static Activator plugin;
//
// /**
// * The constructor
// */
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/support/preferences/PreferenceConstants.java
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.compiler.support.Activator;
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SolC other = (SolC) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (path == null) {
if (other.path != null)
return false;
} else if (!path.equals(other.path))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.equals(other.version))
return false;
return true;
}
}
public static IPreferenceStore getPreferenceStore(IProject project) {
if (project != null) { | IPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID); |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceInitializer.java | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.ui";
//
// /**
// * The shared instance.
// */
// private static Activator plugin;
//
// /**
// * The constructor.
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
| import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.ui.Activator; | package de.urszeidler.eclipse.solidity.ui.preferences;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() { | // Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.ui";
//
// /**
// * The shared instance.
// */
// private static Activator plugin;
//
// /**
// * The constructor.
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.ui/src/de/urszeidler/eclipse/solidity/ui/preferences/PreferenceInitializer.java
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import de.urszeidler.eclipse.solidity.ui.Activator;
package de.urszeidler.eclipse.solidity.ui.preferences;
/**
* Class used to initialize default preference values.
*/
public class PreferenceInitializer extends AbstractPreferenceInitializer {
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
public void initializeDefaultPreferences() { | IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID); |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/propertytester/HasBuilderTester.java | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/handler/AddBuilder.java
// public class AddBuilder extends AbstractHandler implements IHandler {
//
// @Override
// public Object execute(final ExecutionEvent event) {
// final IProject project = getProject(event);
//
// if (project != null) {
// try {
// // verify already registered builders
// if (hasBuilder(project))
// // already enabled
// return null;
//
// // add builder to project properties
// IProjectDescription description = project.getDescription();
// final ICommand buildCommand = description.newCommand();
// buildCommand.setBuilderName(SolidityBuilder.BUILDER_ID);
//
// final List<ICommand> commands = new ArrayList<ICommand>();
// commands.addAll(Arrays.asList(description.getBuildSpec()));
// commands.add(buildCommand);
//
// description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
// project.setDescription(description, null);
//
// } catch (final CoreException e) {
// Activator.logError("Error adding solc builder", e);
// }
// }
// return null;
// }
//
// public static IProject getProject(final ExecutionEvent event) {
// final ISelection selection = HandlerUtil.getCurrentSelection(event);
// if (selection instanceof IStructuredSelection) {
// final Object element = ((IStructuredSelection) selection).getFirstElement();
//
// return (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class);
// }
// return null;
// }
//
// public static final boolean hasBuilder(final IProject project) {
// try {
// for (final ICommand buildSpec : project.getDescription().getBuildSpec()) {
// if (SolidityBuilder.BUILDER_ID.equals(buildSpec.getBuilderName()))
// return true;
// }
// } catch (final CoreException e) {
// }
// return false;
// }
// }
| import de.urszeidler.eclipse.solidity.compiler.handler.AddBuilder;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Platform; | /**
*
*/
package de.urszeidler.eclipse.solidity.compiler.propertytester;
/**
* @author urs
*
*/
public class HasBuilderTester extends PropertyTester {
private static final String IS_ENABLED = "isEnabled";
/*
* (non-Javadoc)
*
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
* java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (IS_ENABLED.equals(property)) {
final IProject project = (IProject) Platform.getAdapterManager().getAdapter(receiver, IProject.class);
if (project != null) | // Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/handler/AddBuilder.java
// public class AddBuilder extends AbstractHandler implements IHandler {
//
// @Override
// public Object execute(final ExecutionEvent event) {
// final IProject project = getProject(event);
//
// if (project != null) {
// try {
// // verify already registered builders
// if (hasBuilder(project))
// // already enabled
// return null;
//
// // add builder to project properties
// IProjectDescription description = project.getDescription();
// final ICommand buildCommand = description.newCommand();
// buildCommand.setBuilderName(SolidityBuilder.BUILDER_ID);
//
// final List<ICommand> commands = new ArrayList<ICommand>();
// commands.addAll(Arrays.asList(description.getBuildSpec()));
// commands.add(buildCommand);
//
// description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
// project.setDescription(description, null);
//
// } catch (final CoreException e) {
// Activator.logError("Error adding solc builder", e);
// }
// }
// return null;
// }
//
// public static IProject getProject(final ExecutionEvent event) {
// final ISelection selection = HandlerUtil.getCurrentSelection(event);
// if (selection instanceof IStructuredSelection) {
// final Object element = ((IStructuredSelection) selection).getFirstElement();
//
// return (IProject) Platform.getAdapterManager().getAdapter(element, IProject.class);
// }
// return null;
// }
//
// public static final boolean hasBuilder(final IProject project) {
// try {
// for (final ICommand buildSpec : project.getDescription().getBuildSpec()) {
// if (SolidityBuilder.BUILDER_ID.equals(buildSpec.getBuilderName()))
// return true;
// }
// } catch (final CoreException e) {
// }
// return false;
// }
// }
// Path: de.urszeidler.eclipse.solidity.compiler.support/src/de/urszeidler/eclipse/solidity/compiler/propertytester/HasBuilderTester.java
import de.urszeidler.eclipse.solidity.compiler.handler.AddBuilder;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Platform;
/**
*
*/
package de.urszeidler.eclipse.solidity.compiler.propertytester;
/**
* @author urs
*
*/
public class HasBuilderTester extends PropertyTester {
private static final String IS_ENABLED = "isEnabled";
/*
* (non-Javadoc)
*
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
* java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (IS_ENABLED.equals(property)) {
final IProject project = (IProject) Platform.getAdapterManager().getAdapter(receiver, IProject.class);
if (project != null) | return AddBuilder.hasBuilder(project); |
UrsZeidler/uml2solidity | de.urszeidler.eclipse.solidity.laucher.ui/src/de/urszeidler/eclipse/solidity/laucher/ui/Uml2SolidityLaunchConfigurationTabGroup.java | // Path: de.urszeidler.eclipse.solidity.laucher.ui/src/de/urszeidler/eclipse/solidity/laucher/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// private static Activator plugin;
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.laucher.ui";
//
// /**
// *
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// @Override
// protected void initializeImageRegistry(ImageRegistry reg) {
// ImageDescriptor image = imageDescriptorFromPlugin(PLUGIN_ID, "images/solidity16.png");
// reg.put("UML2Solidity", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/script_wiz.gif");
// reg.put("JsCode", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/help_topic.gif");
// reg.put("OtherFiles", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/javabean_obj.gif");
// reg.put("JavaCode", image);
//
// super.initializeImageRegistry(reg);
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
| import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import de.urszeidler.eclipse.solidity.laucher.Activator; | *
*/
public Uml2SolidityLaunchConfigurationTabGroup() {
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
.getConfigurationElementsFor("de.urszeidler.eclipse.solidity.um2solidity.m2t.laucherTab");
List<LaunchingConfig> confs = new ArrayList<LaunchingConfig>();
for (IConfigurationElement element : configurationElements) {
ILaunchConfigurationTab tab;
try {
tab = (ILaunchConfigurationTab) element.createExecutableExtension("tab_class");
String orderString = element.getAttribute("tab_order");
int order = 10;
try {
order = Integer.parseInt(orderString);
} catch (NumberFormatException e) {
}
LaunchingConfig launchingConfig = new LaunchingConfig();
launchingConfig.tab = tab;
launchingConfig.order = order;
confs.add(launchingConfig);
} catch (Exception e) { | // Path: de.urszeidler.eclipse.solidity.laucher.ui/src/de/urszeidler/eclipse/solidity/laucher/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// private static Activator plugin;
// /**
// * The plug-in ID.
// */
// public static final String PLUGIN_ID = "de.urszeidler.eclipse.solidity.laucher.ui";
//
// /**
// *
// */
// public Activator() {
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
// * @generated
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// @Override
// protected void initializeImageRegistry(ImageRegistry reg) {
// ImageDescriptor image = imageDescriptorFromPlugin(PLUGIN_ID, "images/solidity16.png");
// reg.put("UML2Solidity", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/script_wiz.gif");
// reg.put("JsCode", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/help_topic.gif");
// reg.put("OtherFiles", image);
// image = imageDescriptorFromPlugin(PLUGIN_ID, "images/javabean_obj.gif");
// reg.put("JavaCode", image);
//
// super.initializeImageRegistry(reg);
// }
//
// /**
// * {@inheritDoc}
// *
// * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
// * @generated
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance.
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void logError(String message, Exception e) {
// getDefault().getLog().log(createErrorStatus(message, e));
// }
//
// public static Status createErrorStatus(String message, Exception e) {
// return new Status(IStatus.ERROR, PLUGIN_ID, message, e);
// }
//
// public static void logError(String message) {
// getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, message));
// }
//
// public static void logInfo(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// public static void logWarning(String message) {
// getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
// }
//
// }
// Path: de.urszeidler.eclipse.solidity.laucher.ui/src/de/urszeidler/eclipse/solidity/laucher/ui/Uml2SolidityLaunchConfigurationTabGroup.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import de.urszeidler.eclipse.solidity.laucher.Activator;
*
*/
public Uml2SolidityLaunchConfigurationTabGroup() {
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
@Override
public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
.getConfigurationElementsFor("de.urszeidler.eclipse.solidity.um2solidity.m2t.laucherTab");
List<LaunchingConfig> confs = new ArrayList<LaunchingConfig>();
for (IConfigurationElement element : configurationElements) {
ILaunchConfigurationTab tab;
try {
tab = (ILaunchConfigurationTab) element.createExecutableExtension("tab_class");
String orderString = element.getAttribute("tab_order");
int order = 10;
try {
order = Integer.parseInt(orderString);
} catch (NumberFormatException e) {
}
LaunchingConfig launchingConfig = new LaunchingConfig();
launchingConfig.tab = tab;
launchingConfig.order = order;
confs.add(launchingConfig);
} catch (Exception e) { | Activator.logError("Error instanciate the tab.", e); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
| import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override | public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
| import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override | public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
| import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | SelectNodeList selectNodeList = StringUtils.isNotEmpty(selectExpression) ? new SelectTokenParserAdapter().parse(selectExpression) : new SelectNodeList(Collections.EMPTY_LIST); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
| import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | SelectNodeList selectNodeList = StringUtils.isNotEmpty(selectExpression) ? new SelectTokenParserAdapter().parse(selectExpression) : new SelectNodeList(Collections.EMPTY_LIST); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
| import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectContext.java
// public class SelectContext<T, E extends SelectParam> {
//
// private SelectBuilder<T, E> selectBuilder;
// private E selectParam;
//
// public static <T, E extends SelectParam> SelectContext<T, E> withBuilderAndParam(SelectBuilder<T, E> builder, E sortParam) {
// return new SelectContext<T, E>()
// .setSelectBuilder(builder)
// .setSelectParam(sortParam);
// }
//
// public SelectBuilder<T, E> getSelectBuilder() {
// return selectBuilder;
// }
//
// public SelectContext setSelectBuilder(SelectBuilder<T, E> selectBuilder) {
// this.selectBuilder = selectBuilder;
// return this;
// }
//
// public E getSelectParam() {
// return selectParam;
// }
//
// public SelectContext<T, E> setSelectParam(E sortParam) {
// this.selectParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectParam.java
// public class SelectParam {
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
// public class SelectTokenParserAdapter {
// public SelectNodeList parse(String sortExpression) {
// try {
// return new SelectNodeList(createParser(sortExpression).parse());
// } catch (ParseException | Error e) {
// throw new SelectParsingException(e);
// }
// }
//
// private SelectTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SelectTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
//
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
import java.util.Collections;
import com.github.vineey.rql.core.util.StringUtils;
import com.github.vineey.rql.select.SelectContext;
import com.github.vineey.rql.select.SelectParam;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.github.vineey.rql.select.parser.ast.SelectTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser;
/**
* @author vrustia - 5/9/16.
*/
public class DefaultSelectParser implements SelectParser {
@Override
public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
E selectParam = selectContext.getSelectParam(); | SelectNodeList selectNodeList = StringUtils.isNotEmpty(selectExpression) ? new SelectTokenParserAdapter().parse(selectExpression) : new SelectNodeList(Collections.EMPTY_LIST); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-select/src/test/java/com/github/vineey/rql/querydsl/select/QuerydslSelectContextTest.java | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
// public class DefaultSelectParser implements SelectParser {
// @Override
// public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
// E selectParam = selectContext.getSelectParam();
// SelectNodeList selectNodeList = StringUtils.isNotEmpty(selectExpression) ? new SelectTokenParserAdapter().parse(selectExpression) : new SelectNodeList(Collections.EMPTY_LIST);
// return selectContext.getSelectBuilder().visit(selectNodeList, selectParam);
//
// }
// }
| import com.querydsl.core.types.Projections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.github.vineey.rql.querydsl.test.mongo.QContactDocument;
import com.github.vineey.rql.select.parser.DefaultSelectParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.select;
/**
* @author vrustia - 5/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslSelectContextTest {
@Test
public void singleSelect() {
String rqlSelectExpression = "select(employee.number)"; | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/DefaultSelectParser.java
// public class DefaultSelectParser implements SelectParser {
// @Override
// public <T, E extends SelectParam> T parse(String selectExpression, SelectContext<T, E> selectContext) {
// E selectParam = selectContext.getSelectParam();
// SelectNodeList selectNodeList = StringUtils.isNotEmpty(selectExpression) ? new SelectTokenParserAdapter().parse(selectExpression) : new SelectNodeList(Collections.EMPTY_LIST);
// return selectContext.getSelectBuilder().visit(selectNodeList, selectParam);
//
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-select/src/test/java/com/github/vineey/rql/querydsl/select/QuerydslSelectContextTest.java
import com.querydsl.core.types.Projections;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.github.vineey.rql.querydsl.test.mongo.QContactDocument;
import com.github.vineey.rql.select.parser.DefaultSelectParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.select;
/**
* @author vrustia - 5/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslSelectContextTest {
@Test
public void singleSelect() {
String rqlSelectExpression = "select(employee.number)"; | DefaultSelectParser selectParser = new DefaultSelectParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
| import com.github.vineey.rql.core.util.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.util;
/**
* @author vrustia on 10/10/2015.
*/
public final class DateUtil {
public static final String DATE_FORMAT = "yyyy-MM-dd";
public static final String TIME_FORMAT = "HH:mm:ss";
public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
public static LocalTime parseLocalTime(String time) { | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
import com.github.vineey.rql.core.util.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.util;
/**
* @author vrustia on 10/10/2015.
*/
public final class DateUtil {
public static final String DATE_FORMAT = "yyyy-MM-dd";
public static final String TIME_FORMAT = "HH:mm:ss";
public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
public static LocalTime parseLocalTime(String time) { | if (StringUtils.isEmpty(time)) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageParser.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
| import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
public class QuerydslPageParser extends DefaultPageParser {
public QueryModifiers parse(String limitExpression) { | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageParser.java
import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
public class QuerydslPageParser extends DefaultPageParser {
public QueryModifiers parse(String limitExpression) { | return super.parse(limitExpression, withDefault()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-sort/src/test/java/com/github/vineey/rql/querydsl/sort/QuerydslSortContextTest.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java
// public class DefaultSortParser implements SortParser {
//
// @Override
// public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) {
// E sortParam = sortContext.getSortParam();
// return sortContext.getSortBuilder().visit(new SortTokenParserAdapter().parse(sortExpression), sortParam);
// }
// }
| import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.github.vineey.rql.sort.parser.DefaultSortParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class QuerydslSortContextTest {
@Test
public void sortToOrderSpecifier_Ascending() {
String sortExpression = "sort(+employeeNumber)"; | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java
// public class DefaultSortParser implements SortParser {
//
// @Override
// public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) {
// E sortParam = sortContext.getSortParam();
// return sortContext.getSortBuilder().visit(new SortTokenParserAdapter().parse(sortExpression), sortParam);
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-sort/src/test/java/com/github/vineey/rql/querydsl/sort/QuerydslSortContextTest.java
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.github.vineey.rql.sort.parser.DefaultSortParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class QuerydslSortContextTest {
@Test
public void sortToOrderSpecifier_Ascending() {
String sortExpression = "sort(+employeeNumber)"; | DefaultSortParser sortParser = new DefaultSortParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/StringPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
| import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.core.types.dsl.StringPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class StringPathConverter implements PathConverter<StringPath> {
private static final String WILDCARD = "*";
@Override
public BooleanExpression evaluate(StringPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
String firstArg = arguments.get(0);
if (EQUAL.equals(comparisonOperator)) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? path.isNull() : equal(path, firstArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? path.isNotNull() : equal(path, firstArg).not().or(path.isNull());
} else if (IN.equals(comparisonOperator)) {
return path.in(arguments);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(arguments);
}
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/StringPathConverter.java
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.StringExpression;
import com.querydsl.core.types.dsl.StringPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class StringPathConverter implements PathConverter<StringPath> {
private static final String WILDCARD = "*";
@Override
public BooleanExpression evaluate(StringPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
String firstArg = arguments.get(0);
if (EQUAL.equals(comparisonOperator)) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? path.isNull() : equal(path, firstArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? path.isNotNull() : equal(path, firstArg).not().or(path.isNull());
} else if (IN.equals(comparisonOperator)) {
return path.in(arguments);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(arguments);
}
| throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/exception/SortParsingException.java
// public class SortParsingException extends RuntimeException {
//
// public SortParsingException(Throwable cause) {
// super(cause);
// }
//
// }
| import com.github.vineey.rql.sort.parser.exception.SortParsingException;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser.ast;
/**
* @author vrustia - 4/10/16.
*/
public class SortTokenParserAdapter {
public SortNodeList parse(String sortExpression) {
try {
return createParser(sortExpression).parse();
} catch (ParseException | Error e) { | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/exception/SortParsingException.java
// public class SortParsingException extends RuntimeException {
//
// public SortParsingException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
import com.github.vineey.rql.sort.parser.exception.SortParsingException;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser.ast;
/**
* @author vrustia - 4/10/16.
*/
public class SortTokenParserAdapter {
public SortNodeList parse(String sortExpression) {
try {
return createParser(sortExpression).parse();
} catch (ParseException | Error e) { | throw new SortParsingException(e); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/NumberPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
| import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.NumberPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/27/2015.
*/
public class NumberPathConverter implements PathConverter<NumberPath> {
@Override
public BooleanExpression evaluate(NumberPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
Number firstNumberArg = convertToNumber(path, arguments.get(0));
if (EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNull() : path.eq(firstNumberArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNotNull() : path.ne(firstNumberArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToNumberArguments(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToNumberArguments(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstNumberArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstNumberArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstNumberArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstNumberArg);
}
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/NumberPathConverter.java
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.NumberPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/27/2015.
*/
public class NumberPathConverter implements PathConverter<NumberPath> {
@Override
public BooleanExpression evaluate(NumberPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
Number firstNumberArg = convertToNumber(path, arguments.get(0));
if (EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNull() : path.eq(firstNumberArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNotNull() : path.ne(firstNumberArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToNumberArguments(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToNumberArguments(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstNumberArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstNumberArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstNumberArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstNumberArg);
}
| throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/NumberPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
| import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.NumberPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List; | } else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNotNull() : path.ne(firstNumberArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToNumberArguments(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToNumberArguments(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstNumberArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstNumberArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstNumberArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstNumberArg);
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private List<Number> convertToNumberArguments(NumberPath path, List<String> arguments) {
List<Number> numberArgs = Lists.newArrayList();
for (String arg : arguments) {
numberArgs.add(convertToNumber(path, arg));
}
return numberArgs;
}
private Number convertToNumber(NumberPath path, String firstArg) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? null | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/NumberPathConverter.java
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.NumberPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List;
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstNumberArg == null ? path.isNotNull() : path.ne(firstNumberArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToNumberArguments(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToNumberArguments(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstNumberArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstNumberArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstNumberArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstNumberArg);
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private List<Number> convertToNumberArguments(NumberPath path, List<String> arguments) {
List<Number> numberArgs = Lists.newArrayList();
for (String arg : arguments) {
numberArgs.add(convertToNumber(path, arg));
}
return numberArgs;
}
private Number convertToNumber(NumberPath path, String firstArg) {
return ConverterConstant.NULL.equalsIgnoreCase(firstArg) ? null | : ConverterUtil.convertToNumber(path.getType(), firstArg); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
| import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java
import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override | public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
| import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java
import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override | public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
| import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override
public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) {
E sortParam = sortContext.getSortParam(); | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortContext.java
// public class SortContext<T, E extends SortParam> {
// private SortBuilder<T, E> sortBuilder;
// private E sortParam;
//
// public static <T, E extends SortParam> SortContext<T, E> withBuilderAndParam(SortBuilder<T, E> builder, E sortParam) {
// return new SortContext<T, E>()
// .setSortBuilder(builder)
// .setSortParam(sortParam);
// }
//
// public SortBuilder<T, E> getSortBuilder() {
// return sortBuilder;
// }
//
// public SortContext setSortBuilder(SortBuilder<T, E> sortBuilder) {
// this.sortBuilder = sortBuilder;
// return this;
// }
//
// public E getSortParam() {
// return sortParam;
// }
//
// public SortContext setSortParam(E sortParam) {
// this.sortParam = sortParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortParam.java
// public class SortParam {
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapter.java
// public class SortTokenParserAdapter {
// public SortNodeList parse(String sortExpression) {
// try {
// return createParser(sortExpression).parse();
// } catch (ParseException | Error e) {
// throw new SortParsingException(e);
// }
// }
//
// private SortTokenParser createParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new SortTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//
// }
// }
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/DefaultSortParser.java
import com.github.vineey.rql.sort.SortContext;
import com.github.vineey.rql.sort.SortParam;
import com.github.vineey.rql.sort.parser.ast.SortTokenParserAdapter;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser;
/**
* @author vrustia - 4/10/16.
*/
public class DefaultSortParser implements SortParser {
@Override
public <T, E extends SortParam> T parse(String sortExpression, SortContext<T, E> sortContext) {
E sortParam = sortContext.getSortParam(); | return sortContext.getSortBuilder().visit(new SortTokenParserAdapter().parse(sortExpression), sortParam); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-select/src/main/java/com/github/vineey/rql/querydsl/select/QuerydslSelectBuilder.java | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectBuilder.java
// public interface SelectBuilder<T, E extends SelectParam> {
// T visit(SelectNodeList node, E selectParam);
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.select.SelectBuilder;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Projections; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.select;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSelectBuilder implements SelectBuilder<Expression, QuerydslSelectParam> {
@Override | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/SelectBuilder.java
// public interface SelectBuilder<T, E extends SelectParam> {
// T visit(SelectNodeList node, E selectParam);
// }
//
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectNodeList.java
// public class SelectNodeList {
// private List<String> fields = new ArrayList<>();
//
// public SelectNodeList(List<String> fields) {
// this.fields = fields;
// }
//
// public List<String> getFields() {
// return fields;
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-select/src/main/java/com/github/vineey/rql/querydsl/select/QuerydslSelectBuilder.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.select.SelectBuilder;
import com.github.vineey.rql.select.parser.ast.SelectNodeList;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Projections;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.select;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSelectBuilder implements SelectBuilder<Expression, QuerydslSelectParam> {
@Override | public Expression visit(SelectNodeList node, QuerydslSelectParam selectParam) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/StringUtilsTest.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
| import com.github.vineey.rql.core.util.StringUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class StringUtilsTest {
@BeforeClass
public static void init() { | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/StringUtilsTest.java
import com.github.vineey.rql.core.util.StringUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class StringUtilsTest {
@BeforeClass
public static void init() { | new StringUtils(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/TimePathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
| import com.querydsl.core.types.dsl.TimePath;
import java.time.LocalTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/10/2015.
*/
public class TimePathConverter extends AbstractTimeRangePathConverter<Comparable, TimePath> implements PathConverter<TimePath> {
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
//TODO convert arg to time with default format
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/TimePathConverter.java
import com.querydsl.core.types.dsl.TimePath;
import java.time.LocalTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/10/2015.
*/
public class TimePathConverter extends AbstractTimeRangePathConverter<Comparable, TimePath> implements PathConverter<TimePath> {
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
//TODO convert arg to time with default format
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | else if (pathFieldType.equals(LocalTime.class)) return DateUtil.parseLocalTime(argument); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL"; | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL"; | FilterParser filterParser = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL"; | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL"; | FilterParser filterParser = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL";
FilterParser filterParser = new DefaultFilterParser(); | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia on 9/26/2015.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_StringPath_Test {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testParse_StringEquals() {
String rqlFilter = "name==KHIEL";
FilterParser filterParser = new DefaultFilterParser(); | Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("name"))); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions; | String rqlFilter = "(firstName==KHIEL;familyName==Rustia),middleName==Laid";
FilterParser filterParser = new DefaultFilterParser();
Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("firstName", "middleName", "familyName")));
assertNotNull(predicate);
assertTrue(predicate instanceof BooleanOperation);
BooleanOperation booleanOperation = (BooleanOperation) predicate;
assertEquals(2, booleanOperation.getArgs().size());
assertEquals("eqIc(firstName,KHIEL) && eqIc(familyName,Rustia)", booleanOperation.getArg(0).toString());
assertEquals("eqIc(middleName,Laid)", booleanOperation.getArg(1).toString());
assertEquals(Ops.OR, booleanOperation.getOperator());
}
@Test
public void testParse_StringOuterAnd_InnerOr_Multiple() {
String rqlFilter = "firstName==KHIEL;(familyName==Rustia,middleName==Laid)";
FilterParser filterParser = new DefaultFilterParser();
Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("firstName", "middleName", "familyName")));
assertNotNull(predicate);
assertTrue(predicate instanceof BooleanOperation);
BooleanOperation booleanOperation = (BooleanOperation) predicate;
assertEquals(2, booleanOperation.getArgs().size());
assertEquals("eqIc(firstName,KHIEL)", booleanOperation.getArg(0).toString());
assertEquals("eqIc(familyName,Rustia) || eqIc(middleName,Laid)", booleanOperation.getArg(1).toString());
assertEquals(Ops.AND, booleanOperation.getOperator());
}
@Test
public void testParse_StringUnsupportedRqlOperator() {
String selector = "status";
String argument = "ACTIVE"; | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_StringPath_Test.java
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.HashMap;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.Maps;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import com.querydsl.core.types.dsl.Expressions;
String rqlFilter = "(firstName==KHIEL;familyName==Rustia),middleName==Laid";
FilterParser filterParser = new DefaultFilterParser();
Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("firstName", "middleName", "familyName")));
assertNotNull(predicate);
assertTrue(predicate instanceof BooleanOperation);
BooleanOperation booleanOperation = (BooleanOperation) predicate;
assertEquals(2, booleanOperation.getArgs().size());
assertEquals("eqIc(firstName,KHIEL) && eqIc(familyName,Rustia)", booleanOperation.getArg(0).toString());
assertEquals("eqIc(middleName,Laid)", booleanOperation.getArg(1).toString());
assertEquals(Ops.OR, booleanOperation.getOperator());
}
@Test
public void testParse_StringOuterAnd_InnerOr_Multiple() {
String rqlFilter = "firstName==KHIEL;(familyName==Rustia,middleName==Laid)";
FilterParser filterParser = new DefaultFilterParser();
Predicate predicate = filterParser.parse(rqlFilter, withBuilderAndParam(new QuerydslFilterBuilder(), createFilterParam("firstName", "middleName", "familyName")));
assertNotNull(predicate);
assertTrue(predicate instanceof BooleanOperation);
BooleanOperation booleanOperation = (BooleanOperation) predicate;
assertEquals(2, booleanOperation.getArgs().size());
assertEquals("eqIc(firstName,KHIEL)", booleanOperation.getArg(0).toString());
assertEquals("eqIc(familyName,Rustia) || eqIc(middleName,Laid)", booleanOperation.getArg(1).toString());
assertEquals(Ops.AND, booleanOperation.getOperator());
}
@Test
public void testParse_StringUnsupportedRqlOperator() {
String selector = "status";
String argument = "ACTIVE"; | String rqlFilter = RSQLUtil.build(selector, RSQLOperators.GREATER_THAN_OR_EQUAL, argument); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
| import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override | public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
| import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override | public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
| import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override
public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) { | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
// private PageBuilder<T, E> pageBuilder;
// private E pageParam;
//
// public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
// return new PageContext<T, E>()
// .setPageBuilder(builder)
// .setPageParam(pageParam);
// }
//
// public PageBuilder<T, E> getPageBuilder() {
// return pageBuilder;
// }
//
// public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
// this.pageBuilder = pageBuilder;
// return this;
// }
//
// public E getPageParam() {
// return pageParam;
// }
//
// public PageContext setPageParam(E pageParam) {
// this.pageParam = pageParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
//
// public PageNode parse(String limitExpression) {
// try {
// return createLimitParser(limitExpression).parse();
// } catch (ParseException | Error e) {
// throw new LimitParsingException(e);
// }
// }
//
// private LimitTokenParser createLimitParser(String expression) {
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
// return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
// }
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;
/**
* @author vrustia - 4/8/16.
*/
public class DefaultPageParser implements PageParser {
private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
@Override
public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) { | PageNode parsedPageNode = limitParserAdapter.parse(limitExpression); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-integrationtest/src/test/java/com/github/vineey/rql/querydsl/test/mongo/FongoConfig.java | // Path: rsql-querydsl-parent/rsql-querydsl-integrationtest/src/main/java/com/github/vineey/rql/querydsl/test/mongo/config/MongoUtil.java
// public class MongoUtil {
//
// private static Mongo mongo;
//
// @Autowired
// public MongoUtil(Mongo mongo) {
// MongoUtil.mongo = mongo;
// }
//
// public static Mongo getMongo() {
// return MongoUtil.mongo;
// }
// }
| import com.github.fakemongo.Fongo;
import com.github.vineey.rql.querydsl.test.mongo.config.MongoUtil;
import com.mongodb.Mongo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.test.mongo;
/**
* @author vrustia - 5/9/16.
*/
@Configuration
public class FongoConfig {
@Bean
public Mongo mongo() throws Exception {
return new Fongo("test").getMongo();
}
@Bean | // Path: rsql-querydsl-parent/rsql-querydsl-integrationtest/src/main/java/com/github/vineey/rql/querydsl/test/mongo/config/MongoUtil.java
// public class MongoUtil {
//
// private static Mongo mongo;
//
// @Autowired
// public MongoUtil(Mongo mongo) {
// MongoUtil.mongo = mongo;
// }
//
// public static Mongo getMongo() {
// return MongoUtil.mongo;
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-integrationtest/src/test/java/com/github/vineey/rql/querydsl/test/mongo/FongoConfig.java
import com.github.fakemongo.Fongo;
import com.github.vineey.rql.querydsl.test.mongo.config.MongoUtil;
import com.mongodb.Mongo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.test.mongo;
/**
* @author vrustia - 5/9/16.
*/
@Configuration
public class FongoConfig {
@Bean
public Mongo mongo() throws Exception {
return new Fongo("test").getMongo();
}
@Bean | public MongoUtil mongoUtil(Mongo mongo) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_CollectionPath_Test {
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_CollectionPath_Test {
| private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_CollectionPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void collectionNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
String rqlFilter = "employee.nameCollection=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_CollectionPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void collectionNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
String rqlFilter = "employee.nameCollection=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | withBuilderAndParam(new QuerydslFilterBuilder(), new QuerydslFilterParam() |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test; |
assertNotNull(predicate);
BooleanOperation sizeExpression = (BooleanOperation) predicate;
assertEquals("size(employee.nameCollection) = 0", sizeExpression.toString());
}
@Test
public void collectionSizeEquals() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
String rqlFilter = "employee.nameCollection=size=5";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter,
withBuilderAndParam(new QuerydslFilterBuilder(), new QuerydslFilterParam()
.setMapping(pathHashMap)));
assertNotNull(predicate);
BooleanOperation sizeExpression = (BooleanOperation) predicate;
assertEquals("size(employee.nameCollection) = 5", sizeExpression.toString());
}
@Test
public void collection_UnSupportedOperator() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_CollectionPath_Test.java
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
import org.junit.Rule;
import org.junit.Test;
assertNotNull(predicate);
BooleanOperation sizeExpression = (BooleanOperation) predicate;
assertEquals("size(employee.nameCollection) = 0", sizeExpression.toString());
}
@Test
public void collectionSizeEquals() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
String rqlFilter = "employee.nameCollection=size=5";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter,
withBuilderAndParam(new QuerydslFilterBuilder(), new QuerydslFilterParam()
.setMapping(pathHashMap)));
assertNotNull(predicate);
BooleanOperation sizeExpression = (BooleanOperation) predicate;
assertEquals("size(employee.nameCollection) = 5", sizeExpression.toString());
}
@Test
public void collection_UnSupportedOperator() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameCollection", employee.nameCollection)
.build();
| String rqlFilter = RSQLUtil.build("employee.nameCollection", RSQLOperators.IN, "test"); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
| import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
| // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java
import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
| if (SIZE_EQ.equals(comparisonOperator)) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
| import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)); | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java
import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)); | } else if (SIZE_NOT_EQ.equals(comparisonOperator)) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
| import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument));
} else if (SIZE_NOT_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)).not();
}
| // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java
import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument));
} else if (SIZE_NOT_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)).not();
}
| throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
| import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument));
} else if (SIZE_NOT_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)).not();
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private String getArgument(ComparisonNode comparisonNode) {
List<String> arguments = comparisonNode.getArguments(); | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractCollectionPathConverter.java
import com.github.vineey.rql.core.util.CollectionUtils;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CollectionPathBase;
import com.querydsl.core.types.dsl.SimpleExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.Collection;
import java.util.List;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_EQ;
import static com.github.vineey.rql.filter.operator.QRSQLOperators.SIZE_NOT_EQ;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia - 3/25/16.
*/
public abstract class AbstractCollectionPathConverter<E, Q extends SimpleExpression<? super E>, COLLECTION extends Collection<E>, PATH extends CollectionPathBase<COLLECTION, E, Q>> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
String argument = getArgument(comparisonNode);
if (SIZE_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument));
} else if (SIZE_NOT_EQ.equals(comparisonOperator)) {
return path.size().eq(convertToSize(argument)).not();
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private String getArgument(ComparisonNode comparisonNode) {
List<String> arguments = comparisonNode.getArguments(); | return CollectionUtils.isNotEmpty(arguments) ? arguments.get(0) : null; |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-sort/src/main/java/com/github/vineey/rql/querydsl/sort/QuerydslSortBuilder.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortBuilder.java
// public interface SortBuilder<T, E extends SortParam> {
// T visit(SortNodeList node, E filterParam);
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNode.java
// public class SortNode {
// public enum Order {
// ASC("+"),
// DESC("-")
// ;
// private String symbol;
// Order(String symbol){
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public static Order get(String orderSymbol) {
// for(Order order : Order.values()){
// if(order.getSymbol().equals(orderSymbol)) {
// return order;
// }
// }
// throw new IllegalArgumentException("SortNode.Order has no matching enum value for symbol : ["+ orderSymbol +"}");
// }
//
// }
//
// private String field;
// private Order order;
//
// public String getField() {
// return field;
// }
//
// public SortNode setField(String field) {
// this.field = field;
// return this;
// }
//
// public Order getOrder() {
// return order;
// }
//
// public SortNode setOrder(Order order) {
// this.order = order;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNodeList.java
// public class SortNodeList {
// private List<SortNode> nodes = new ArrayList<>();
//
// public void add(SortNode sortNode) {
// this.nodes.add(sortNode);
// }
//
// public List<SortNode> getNodes() {
// return nodes;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.sort.SortBuilder;
import com.github.vineey.rql.sort.parser.ast.SortNode;
import com.github.vineey.rql.sort.parser.ast.SortNodeList;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSortBuilder implements SortBuilder<OrderSpecifierList, QuerydslSortParam> {
@Override | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortBuilder.java
// public interface SortBuilder<T, E extends SortParam> {
// T visit(SortNodeList node, E filterParam);
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNode.java
// public class SortNode {
// public enum Order {
// ASC("+"),
// DESC("-")
// ;
// private String symbol;
// Order(String symbol){
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public static Order get(String orderSymbol) {
// for(Order order : Order.values()){
// if(order.getSymbol().equals(orderSymbol)) {
// return order;
// }
// }
// throw new IllegalArgumentException("SortNode.Order has no matching enum value for symbol : ["+ orderSymbol +"}");
// }
//
// }
//
// private String field;
// private Order order;
//
// public String getField() {
// return field;
// }
//
// public SortNode setField(String field) {
// this.field = field;
// return this;
// }
//
// public Order getOrder() {
// return order;
// }
//
// public SortNode setOrder(Order order) {
// this.order = order;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNodeList.java
// public class SortNodeList {
// private List<SortNode> nodes = new ArrayList<>();
//
// public void add(SortNode sortNode) {
// this.nodes.add(sortNode);
// }
//
// public List<SortNode> getNodes() {
// return nodes;
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-sort/src/main/java/com/github/vineey/rql/querydsl/sort/QuerydslSortBuilder.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.sort.SortBuilder;
import com.github.vineey.rql.sort.parser.ast.SortNode;
import com.github.vineey.rql.sort.parser.ast.SortNodeList;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSortBuilder implements SortBuilder<OrderSpecifierList, QuerydslSortParam> {
@Override | public OrderSpecifierList visit(SortNodeList node, QuerydslSortParam filterParam) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-sort/src/main/java/com/github/vineey/rql/querydsl/sort/QuerydslSortBuilder.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortBuilder.java
// public interface SortBuilder<T, E extends SortParam> {
// T visit(SortNodeList node, E filterParam);
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNode.java
// public class SortNode {
// public enum Order {
// ASC("+"),
// DESC("-")
// ;
// private String symbol;
// Order(String symbol){
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public static Order get(String orderSymbol) {
// for(Order order : Order.values()){
// if(order.getSymbol().equals(orderSymbol)) {
// return order;
// }
// }
// throw new IllegalArgumentException("SortNode.Order has no matching enum value for symbol : ["+ orderSymbol +"}");
// }
//
// }
//
// private String field;
// private Order order;
//
// public String getField() {
// return field;
// }
//
// public SortNode setField(String field) {
// this.field = field;
// return this;
// }
//
// public Order getOrder() {
// return order;
// }
//
// public SortNode setOrder(Order order) {
// this.order = order;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNodeList.java
// public class SortNodeList {
// private List<SortNode> nodes = new ArrayList<>();
//
// public void add(SortNode sortNode) {
// this.nodes.add(sortNode);
// }
//
// public List<SortNode> getNodes() {
// return nodes;
// }
// }
| import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.sort.SortBuilder;
import com.github.vineey.rql.sort.parser.ast.SortNode;
import com.github.vineey.rql.sort.parser.ast.SortNodeList;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSortBuilder implements SortBuilder<OrderSpecifierList, QuerydslSortParam> {
@Override
public OrderSpecifierList visit(SortNodeList node, QuerydslSortParam filterParam) { | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/SortBuilder.java
// public interface SortBuilder<T, E extends SortParam> {
// T visit(SortNodeList node, E filterParam);
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNode.java
// public class SortNode {
// public enum Order {
// ASC("+"),
// DESC("-")
// ;
// private String symbol;
// Order(String symbol){
// this.symbol = symbol;
// }
//
// public String getSymbol() {
// return symbol;
// }
//
// public static Order get(String orderSymbol) {
// for(Order order : Order.values()){
// if(order.getSymbol().equals(orderSymbol)) {
// return order;
// }
// }
// throw new IllegalArgumentException("SortNode.Order has no matching enum value for symbol : ["+ orderSymbol +"}");
// }
//
// }
//
// private String field;
// private Order order;
//
// public String getField() {
// return field;
// }
//
// public SortNode setField(String field) {
// this.field = field;
// return this;
// }
//
// public Order getOrder() {
// return order;
// }
//
// public SortNode setOrder(Order order) {
// this.order = order;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/ast/SortNodeList.java
// public class SortNodeList {
// private List<SortNode> nodes = new ArrayList<>();
//
// public void add(SortNode sortNode) {
// this.nodes.add(sortNode);
// }
//
// public List<SortNode> getNodes() {
// return nodes;
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-sort/src/main/java/com/github/vineey/rql/querydsl/sort/QuerydslSortBuilder.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.github.vineey.rql.sort.SortBuilder;
import com.github.vineey.rql.sort.parser.ast.SortNode;
import com.github.vineey.rql.sort.parser.ast.SortNodeList;
import com.querydsl.core.types.Order;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.Path;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.sort;
/**
* @author vrustia - 4/17/16.
*/
public class QuerydslSortBuilder implements SortBuilder<OrderSpecifierList, QuerydslSortParam> {
@Override
public OrderSpecifierList visit(SortNodeList node, QuerydslSortParam filterParam) { | List<SortNode> sortNodes = node.getNodes(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/DateUtilTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDateTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class DateUtilTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@BeforeClass
public static void init(){ | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/DateUtilTest.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDateTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class DateUtilTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@BeforeClass
public static void init(){ | new DateUtil(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() { | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() { | new ConverterUtil(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() {
new ConverterUtil();
}
@Test
public void convertAllClass() {
String argument = "1";
Class[] classes = new Class[]{Long.class, Integer.class, Double.class, Float.class, BigInteger.class, BigDecimal.class, Short.class};
for (Class clazz : classes)
Assert.assertEquals(clazz, ConverterUtil.convert(clazz, argument).getClass());
}
@Test(expected = UnsupportedOperationException.class)
public void convertNumberNotSUpported() {
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() {
new ConverterUtil();
}
@Test
public void convertAllClass() {
String argument = "1";
Class[] classes = new Class[]{Long.class, Integer.class, Double.class, Float.class, BigInteger.class, BigDecimal.class, Short.class};
for (Class clazz : classes)
Assert.assertEquals(clazz, ConverterUtil.convert(clazz, argument).getClass());
}
@Test(expected = UnsupportedOperationException.class)
public void convertNumberNotSUpported() {
| ConverterUtil.convert(CustomNumber.class, "1"); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() {
new ConverterUtil();
}
@Test
public void convertAllClass() {
String argument = "1";
Class[] classes = new Class[]{Long.class, Integer.class, Double.class, Float.class, BigInteger.class, BigDecimal.class, Short.class};
for (Class clazz : classes)
Assert.assertEquals(clazz, ConverterUtil.convert(clazz, argument).getClass());
}
@Test(expected = UnsupportedOperationException.class)
public void convertNumberNotSUpported() {
ConverterUtil.convert(CustomNumber.class, "1");
}
@Test(expected = UnsupportedOperationException.class)
public void convertNotSUpported() {
ConverterUtil.convert(Month.class, "1");
}
@Test
public void convertNull() {
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/CustomNumber.java
// public class CustomNumber extends Number implements Comparable {
// @Override
// public double doubleValue() {
// return 0;
// }
//
// @Override
// public int intValue() {
// return 0;
// }
//
// @Override
// public long longValue() {
// return 0;
// }
//
// @Override
// public float floatValue() {
// return 0;
// }
//
// @Override
// public int compareTo(Object o) {
// return 0;
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/ConverterConstant.java
// public interface ConverterConstant {
// String NULL = "NULL";
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/ConverterUtil.java
// public final class ConverterUtil {
//
// public static Object convert(Class<?> clazz, String arg) {
// if (NULL.equalsIgnoreCase(arg)) {
// return null;
// } else if (Number.class.isAssignableFrom(clazz)) {
// Class<? extends Number> numberClass = (Class<? extends Number>) clazz;
// return convertToNumber(numberClass, arg);
// } else {
// throw new UnsupportedOperationException("Conversion not support for " + clazz);
//
// }
//
// }
//
// public static <E extends Number> Number convertToNumber(Class<E> clazz, String arg) {
// if (clazz.equals(Long.class)) {
// return Long.valueOf(arg);
// } else if (clazz.equals(Double.class)) {
// return Double.valueOf(arg);
// } else if (clazz.equals(Integer.class)) {
// return Integer.valueOf(arg);
// } else if (clazz.equals(BigDecimal.class)) {
// return new BigDecimal(arg);
// } else if (clazz.equals(Short.class)) {
// return new Short(arg);
// } else if (clazz.equals(BigInteger.class)) {
// return new BigInteger(arg);
// } else if (clazz.equals(Float.class)) {
// return Float.valueOf(arg);
// } else {
// throw new UnsupportedOperationException("Conversion to Number doesn't support " + clazz);
// }
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/ConverterUtilTest.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.CustomNumber;
import com.github.vineey.rql.querydsl.filter.converter.ConverterConstant;
import com.github.vineey.rql.querydsl.filter.util.ConverterUtil;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class ConverterUtilTest {
@BeforeClass
public static void init() {
new ConverterUtil();
}
@Test
public void convertAllClass() {
String argument = "1";
Class[] classes = new Class[]{Long.class, Integer.class, Double.class, Float.class, BigInteger.class, BigDecimal.class, Short.class};
for (Class clazz : classes)
Assert.assertEquals(clazz, ConverterUtil.convert(clazz, argument).getClass());
}
@Test(expected = UnsupportedOperationException.class)
public void convertNumberNotSUpported() {
ConverterUtil.convert(CustomNumber.class, "1");
}
@Test(expected = UnsupportedOperationException.class)
public void convertNotSUpported() {
ConverterUtil.convert(Month.class, "1");
}
@Test
public void convertNull() {
| Assert.assertNull(ConverterUtil.convert(Month.class, ConverterConstant.NULL)); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/BooleanPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
| import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.BooleanPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.EQUAL;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.NOT_EQUAL; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/10/2015.
*/
public class BooleanPathConverter implements PathConverter<BooleanPath> {
@Override
public BooleanExpression evaluate(BooleanPath path, ComparisonNode comparisonNode) {
Boolean arg = convertToBoolean(comparisonNode);
ComparisonOperator operator = comparisonNode.getOperator();
if (arg == null) {
return path.isNull();
} else {
if (EQUAL.equals(operator)) {
return path.eq(arg);
} else if (NOT_EQUAL.equals(operator)) {
return path.ne(arg).or(path.isNull());
}
}
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/BooleanPathConverter.java
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.BooleanPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.EQUAL;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.NOT_EQUAL;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/10/2015.
*/
public class BooleanPathConverter implements PathConverter<BooleanPath> {
@Override
public BooleanExpression evaluate(BooleanPath path, ComparisonNode comparisonNode) {
Boolean arg = convertToBoolean(comparisonNode);
ComparisonOperator operator = comparisonNode.getOperator();
if (arg == null) {
return path.isNull();
} else {
if (EQUAL.equals(operator)) {
return path.eq(arg);
} else if (NOT_EQUAL.equals(operator)) {
return path.ne(arg).or(path.isNull());
}
}
| throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/QuerydslRsqlVisitor.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/PathConverterContext.java
// public final class PathConverterContext {
// private static final StringPathConverter STRING_PATH_CONVERTER = new StringPathConverter();
// private static final EnumPathConverter ENUM_PATH_CONVERTER = new EnumPathConverter();
// private static final NumberPathConverter NUMBER_PATH_CONVERTER = new NumberPathConverter();
// private static final BooleanPathConverter BOOLEAN_PATH_CONVERTER = new BooleanPathConverter();
// private static final TimePathConverter TIME_PATH_CONVERTER = new TimePathConverter();
// private static final DateTimePathConverter DATE_TIME_PATH_CONVERTER = new DateTimePathConverter();
// private static final DatePathConverter DATE_PATH_CONVERTER = new DatePathConverter();
// private static final DefaultCollectionPathConverter<Object, SimpleExpression<? super Object>,
// Collection<Object>, CollectionPathBase<Collection<Object>,
// Object,
// SimpleExpression<? super Object>>> DEFAULT_COLLECTION_PATH_CONVERTER = new DefaultCollectionPathConverter<>();
// private final static ImmutableMap<Class<? extends Path>, PathConverter> map = ImmutableMap.<Class<? extends Path>, PathConverter>builder()
// .put(StringPath.class, STRING_PATH_CONVERTER)
// .put(EnumPath.class, ENUM_PATH_CONVERTER)
// .put(NumberPath.class, NUMBER_PATH_CONVERTER)
// .put(BooleanPath.class, BOOLEAN_PATH_CONVERTER)
// .put(TimePath.class, TIME_PATH_CONVERTER)
// .put(DateTimePath.class, DATE_TIME_PATH_CONVERTER)
// .put(DatePath.class, DATE_PATH_CONVERTER)
// .put(ListPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(SetPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(CollectionPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .build();
//
// public static PathConverter getOperator(Path path) {
// return map.get(path.getClass());
// }
// }
| import com.github.vineey.rql.querydsl.filter.converter.PathConverterContext;
import com.google.common.collect.Lists;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cz.jirutka.rsql.parser.ast.*;
import java.util.List; |
List<Node> children = Lists.newArrayList(node.getChildren());
Node firstNode = children.remove(0);
BooleanExpression predicate = (BooleanExpression) firstNode.accept(this, param);
for (Node subNode : children) {
BooleanExpression subPredicate = (BooleanExpression) subNode.accept(this, param);
predicate = combineByLogicalExpression(logicalOperator, predicate, subPredicate);
}
return predicate;
}
private BooleanExpression combineByLogicalExpression(Ops logicalOperator, BooleanExpression predicate, Predicate subPredicate) {
BooleanExpression combinedPredicate = predicate;
if (Ops.AND.equals(logicalOperator)) {
combinedPredicate = predicate.and(subPredicate);
} else if (Ops.OR.equals(logicalOperator)) {
combinedPredicate = predicate.or(subPredicate);
}
return combinedPredicate;
}
@Override
public Predicate visit(OrNode node, QuerydslFilterParam param) {
return evaluateLogicalExpression(node, param, Ops.OR);
}
@Override
public Predicate visit(ComparisonNode node, QuerydslFilterParam param) {
String selector = node.getSelector();
Path path = param.getMapping().get(selector); | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/PathConverterContext.java
// public final class PathConverterContext {
// private static final StringPathConverter STRING_PATH_CONVERTER = new StringPathConverter();
// private static final EnumPathConverter ENUM_PATH_CONVERTER = new EnumPathConverter();
// private static final NumberPathConverter NUMBER_PATH_CONVERTER = new NumberPathConverter();
// private static final BooleanPathConverter BOOLEAN_PATH_CONVERTER = new BooleanPathConverter();
// private static final TimePathConverter TIME_PATH_CONVERTER = new TimePathConverter();
// private static final DateTimePathConverter DATE_TIME_PATH_CONVERTER = new DateTimePathConverter();
// private static final DatePathConverter DATE_PATH_CONVERTER = new DatePathConverter();
// private static final DefaultCollectionPathConverter<Object, SimpleExpression<? super Object>,
// Collection<Object>, CollectionPathBase<Collection<Object>,
// Object,
// SimpleExpression<? super Object>>> DEFAULT_COLLECTION_PATH_CONVERTER = new DefaultCollectionPathConverter<>();
// private final static ImmutableMap<Class<? extends Path>, PathConverter> map = ImmutableMap.<Class<? extends Path>, PathConverter>builder()
// .put(StringPath.class, STRING_PATH_CONVERTER)
// .put(EnumPath.class, ENUM_PATH_CONVERTER)
// .put(NumberPath.class, NUMBER_PATH_CONVERTER)
// .put(BooleanPath.class, BOOLEAN_PATH_CONVERTER)
// .put(TimePath.class, TIME_PATH_CONVERTER)
// .put(DateTimePath.class, DATE_TIME_PATH_CONVERTER)
// .put(DatePath.class, DATE_PATH_CONVERTER)
// .put(ListPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(SetPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(CollectionPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .build();
//
// public static PathConverter getOperator(Path path) {
// return map.get(path.getClass());
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/QuerydslRsqlVisitor.java
import com.github.vineey.rql.querydsl.filter.converter.PathConverterContext;
import com.google.common.collect.Lists;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import cz.jirutka.rsql.parser.ast.*;
import java.util.List;
List<Node> children = Lists.newArrayList(node.getChildren());
Node firstNode = children.remove(0);
BooleanExpression predicate = (BooleanExpression) firstNode.accept(this, param);
for (Node subNode : children) {
BooleanExpression subPredicate = (BooleanExpression) subNode.accept(this, param);
predicate = combineByLogicalExpression(logicalOperator, predicate, subPredicate);
}
return predicate;
}
private BooleanExpression combineByLogicalExpression(Ops logicalOperator, BooleanExpression predicate, Predicate subPredicate) {
BooleanExpression combinedPredicate = predicate;
if (Ops.AND.equals(logicalOperator)) {
combinedPredicate = predicate.and(subPredicate);
} else if (Ops.OR.equals(logicalOperator)) {
combinedPredicate = predicate.or(subPredicate);
}
return combinedPredicate;
}
@Override
public Predicate visit(OrNode node, QuerydslFilterParam param) {
return evaluateLogicalExpression(node, param, Ops.OR);
}
@Override
public Predicate visit(ComparisonNode node, QuerydslFilterParam param) {
String selector = node.getSelector();
Path path = param.getMapping().get(selector); | return PathConverterContext.getOperator(path).evaluate(path, node); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/PathConverterContextTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/PathConverterContext.java
// public final class PathConverterContext {
// private static final StringPathConverter STRING_PATH_CONVERTER = new StringPathConverter();
// private static final EnumPathConverter ENUM_PATH_CONVERTER = new EnumPathConverter();
// private static final NumberPathConverter NUMBER_PATH_CONVERTER = new NumberPathConverter();
// private static final BooleanPathConverter BOOLEAN_PATH_CONVERTER = new BooleanPathConverter();
// private static final TimePathConverter TIME_PATH_CONVERTER = new TimePathConverter();
// private static final DateTimePathConverter DATE_TIME_PATH_CONVERTER = new DateTimePathConverter();
// private static final DatePathConverter DATE_PATH_CONVERTER = new DatePathConverter();
// private static final DefaultCollectionPathConverter<Object, SimpleExpression<? super Object>,
// Collection<Object>, CollectionPathBase<Collection<Object>,
// Object,
// SimpleExpression<? super Object>>> DEFAULT_COLLECTION_PATH_CONVERTER = new DefaultCollectionPathConverter<>();
// private final static ImmutableMap<Class<? extends Path>, PathConverter> map = ImmutableMap.<Class<? extends Path>, PathConverter>builder()
// .put(StringPath.class, STRING_PATH_CONVERTER)
// .put(EnumPath.class, ENUM_PATH_CONVERTER)
// .put(NumberPath.class, NUMBER_PATH_CONVERTER)
// .put(BooleanPath.class, BOOLEAN_PATH_CONVERTER)
// .put(TimePath.class, TIME_PATH_CONVERTER)
// .put(DateTimePath.class, DATE_TIME_PATH_CONVERTER)
// .put(DatePath.class, DATE_PATH_CONVERTER)
// .put(ListPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(SetPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(CollectionPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .build();
//
// public static PathConverter getOperator(Path path) {
// return map.get(path.getClass());
// }
// }
| import com.github.vineey.rql.querydsl.filter.converter.PathConverterContext;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class PathConverterContextTest {
@BeforeClass
public static void init(){ | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/PathConverterContext.java
// public final class PathConverterContext {
// private static final StringPathConverter STRING_PATH_CONVERTER = new StringPathConverter();
// private static final EnumPathConverter ENUM_PATH_CONVERTER = new EnumPathConverter();
// private static final NumberPathConverter NUMBER_PATH_CONVERTER = new NumberPathConverter();
// private static final BooleanPathConverter BOOLEAN_PATH_CONVERTER = new BooleanPathConverter();
// private static final TimePathConverter TIME_PATH_CONVERTER = new TimePathConverter();
// private static final DateTimePathConverter DATE_TIME_PATH_CONVERTER = new DateTimePathConverter();
// private static final DatePathConverter DATE_PATH_CONVERTER = new DatePathConverter();
// private static final DefaultCollectionPathConverter<Object, SimpleExpression<? super Object>,
// Collection<Object>, CollectionPathBase<Collection<Object>,
// Object,
// SimpleExpression<? super Object>>> DEFAULT_COLLECTION_PATH_CONVERTER = new DefaultCollectionPathConverter<>();
// private final static ImmutableMap<Class<? extends Path>, PathConverter> map = ImmutableMap.<Class<? extends Path>, PathConverter>builder()
// .put(StringPath.class, STRING_PATH_CONVERTER)
// .put(EnumPath.class, ENUM_PATH_CONVERTER)
// .put(NumberPath.class, NUMBER_PATH_CONVERTER)
// .put(BooleanPath.class, BOOLEAN_PATH_CONVERTER)
// .put(TimePath.class, TIME_PATH_CONVERTER)
// .put(DateTimePath.class, DATE_TIME_PATH_CONVERTER)
// .put(DatePath.class, DATE_PATH_CONVERTER)
// .put(ListPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(SetPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .put(CollectionPath.class, DEFAULT_COLLECTION_PATH_CONVERTER)
// .build();
//
// public static PathConverter getOperator(Path path) {
// return map.get(path.getClass());
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/PathConverterContextTest.java
import com.github.vineey.rql.querydsl.filter.converter.PathConverterContext;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class PathConverterContextTest {
@BeforeClass
public static void init(){ | new PathConverterContext(); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/test/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapterTest.java | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/exception/SelectParsingException.java
// public class SelectParsingException extends RuntimeException {
// public SelectParsingException(Throwable throwable) {
// super(throwable);
// }
// }
| import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.select.parser.exception.SelectParsingException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser.ast;
/**
* @author vrustia - 5/7/16.
*/
@RunWith(JUnit4.class)
public class SelectTokenParserAdapterTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void parseSelect() {
String selectExpression = "select (employee.name, employee.age, employee.number) ";
SelectNodeList sortNodeList = new SelectTokenParserAdapter().parse(selectExpression);
assertNotNull(sortNodeList);
List<String> sortNodes = sortNodeList.getFields();
assertEquals(3, sortNodes.size());
String firstField = sortNodes.get(0);
assertEquals("employee.name", firstField);
String secondField = sortNodes.get(1);
assertEquals("employee.age", secondField);
String thirdField = sortNodes.get(2);
assertEquals("employee.number", thirdField);
}
@Test
public void parseSelect_Error() {
String sortExpression = "select (+employee.name) "; | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/exception/SelectParsingException.java
// public class SelectParsingException extends RuntimeException {
// public SelectParsingException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: rsql-api-parent/rsql-api-select/src/test/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapterTest.java
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.select.parser.exception.SelectParsingException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser.ast;
/**
* @author vrustia - 5/7/16.
*/
@RunWith(JUnit4.class)
public class SelectTokenParserAdapterTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void parseSelect() {
String selectExpression = "select (employee.name, employee.age, employee.number) ";
SelectNodeList sortNodeList = new SelectTokenParserAdapter().parse(selectExpression);
assertNotNull(sortNodeList);
List<String> sortNodes = sortNodeList.getFields();
assertEquals(3, sortNodes.size());
String firstField = sortNodes.get(0);
assertEquals("employee.name", firstField);
String secondField = sortNodes.get(1);
assertEquals("employee.age", secondField);
String thirdField = sortNodes.get(2);
assertEquals("employee.number", thirdField);
}
@Test
public void parseSelect_Error() {
String sortExpression = "select (+employee.name) "; | thrown.expect(SelectParsingException.class); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-sort/src/test/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapterTest.java | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/exception/SortParsingException.java
// public class SortParsingException extends RuntimeException {
//
// public SortParsingException(Throwable cause) {
// super(cause);
// }
//
// }
| import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.sort.parser.exception.SortParsingException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser.ast;
/**
* @author vrustia - 4/10/16.
*/
@RunWith(JUnit4.class)
public class SortTokenParserAdapterTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void parseSingleSort_Ascending() {
String sortExpression = "sort (+ employee.name) ";
SortNodeList sortNodeList = new SortTokenParserAdapter().parse(sortExpression);
assertNotNull(sortNodeList);
List<SortNode> sortNodes = sortNodeList.getNodes();
assertEquals(1, sortNodes.size());
SortNode sortNode = sortNodes.get(0);
assertEquals("employee.name", sortNode.getField());
assertEquals(SortNode.Order.ASC, sortNode.getOrder());
}
@Test
public void parseSingleSort_Descending() {
String sortExpression = "sort ( - employee.name) ";
SortNodeList sortNodeList = new SortTokenParserAdapter().parse(sortExpression);
assertNotNull(sortNodeList);
List<SortNode> sortNodes = sortNodeList.getNodes();
assertEquals(1, sortNodes.size());
SortNode sortNode = sortNodes.get(0);
assertEquals("employee.name", sortNode.getField());
assertEquals(SortNode.Order.DESC, sortNode.getOrder());
}
@Test
public void parseSingleSort_Error() {
String sortExpression = "sort (+- employee.name) "; | // Path: rsql-api-parent/rsql-api-sort/src/main/java/com/github/vineey/rql/sort/parser/exception/SortParsingException.java
// public class SortParsingException extends RuntimeException {
//
// public SortParsingException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: rsql-api-parent/rsql-api-sort/src/test/java/com/github/vineey/rql/sort/parser/ast/SortTokenParserAdapterTest.java
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.sort.parser.exception.SortParsingException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.sort.parser.ast;
/**
* @author vrustia - 4/10/16.
*/
@RunWith(JUnit4.class)
public class SortTokenParserAdapterTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void parseSingleSort_Ascending() {
String sortExpression = "sort (+ employee.name) ";
SortNodeList sortNodeList = new SortTokenParserAdapter().parse(sortExpression);
assertNotNull(sortNodeList);
List<SortNode> sortNodes = sortNodeList.getNodes();
assertEquals(1, sortNodes.size());
SortNode sortNode = sortNodes.get(0);
assertEquals("employee.name", sortNode.getField());
assertEquals(SortNode.Order.ASC, sortNode.getOrder());
}
@Test
public void parseSingleSort_Descending() {
String sortExpression = "sort ( - employee.name) ";
SortNodeList sortNodeList = new SortTokenParserAdapter().parse(sortExpression);
assertNotNull(sortNodeList);
List<SortNode> sortNodes = sortNodeList.getNodes();
assertEquals(1, sortNodes.size());
SortNode sortNode = sortNodes.get(0);
assertEquals("employee.name", sortNode.getField());
assertEquals(SortNode.Order.DESC, sortNode.getOrder());
}
@Test
public void parseSingleSort_Error() {
String sortExpression = "sort (+- employee.name) "; | thrown.expect(SortParsingException.class); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/DatePathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
| import com.github.vineey.rql.querydsl.filter.util.DateUtil;
import com.querydsl.core.types.dsl.DatePath;
import java.time.LocalDate; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public class DatePathConverter extends AbstractTimeRangePathConverter<Comparable, DatePath> implements PathConverter<DatePath> {
@Override
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/DatePathConverter.java
import com.github.vineey.rql.querydsl.filter.util.DateUtil;
import com.querydsl.core.types.dsl.DatePath;
import java.time.LocalDate;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public class DatePathConverter extends AbstractTimeRangePathConverter<Comparable, DatePath> implements PathConverter<DatePath> {
@Override
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | else if (pathFieldType.equals(LocalDate.class)) return DateUtil.parseLocalDate(argument); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/DateTimePathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
| import com.querydsl.core.types.dsl.DateTimePath;
import java.time.LocalDateTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public class DateTimePathConverter extends AbstractTimeRangePathConverter<Comparable, DateTimePath> implements PathConverter<DateTimePath> {
@Override
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/DateUtil.java
// public final class DateUtil {
// public static final String DATE_FORMAT = "yyyy-MM-dd";
// public static final String TIME_FORMAT = "HH:mm:ss";
// public static final String DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT;
// public final static DateTimeFormatter LOCAL_DATE_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT);
// public final static DateTimeFormatter LOCAL_TIME_FORMATTER = DateTimeFormatter.ofPattern(TIME_FORMAT);
// public final static DateTimeFormatter LOCAL_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
//
// public static LocalTime parseLocalTime(String time) {
// if (StringUtils.isEmpty(time)) {
// return null;
// }
//
// return LocalTime.parse(time, LOCAL_TIME_FORMATTER);
// }
//
// public static String formatLocalTime(LocalTime time) {
// return time.format(LOCAL_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDateTime(LocalDateTime localDateTime) {
// return localDateTime.format(LOCAL_DATE_TIME_FORMATTER);
// }
//
// public static LocalDateTime parseLocalDateTime(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
//
// if (dateTime.length() == DATE_FORMAT.length()) {
// return LocalDateTime.of(LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER), LocalTime.MIDNIGHT);
// }
//
// return LocalDateTime.parse(dateTime, LOCAL_DATE_TIME_FORMATTER);
// }
//
//
// public static String formatLocalDate(LocalDate localDate) {
// return localDate.format(LOCAL_DATE_FORMATTER);
// }
//
// public static LocalDate parseLocalDate(String dateTime) {
// if (StringUtils.isEmpty(dateTime)) {
// return null;
// }
// return LocalDate.parse(dateTime, LOCAL_DATE_FORMATTER);
// }
//
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/DateTimePathConverter.java
import com.querydsl.core.types.dsl.DateTimePath;
import java.time.LocalDateTime;
import com.github.vineey.rql.querydsl.filter.util.DateUtil;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public class DateTimePathConverter extends AbstractTimeRangePathConverter<Comparable, DateTimePath> implements PathConverter<DateTimePath> {
@Override
protected Comparable convertArgument(Class<Comparable> pathFieldType, String argument) {
if (ConverterConstant.NULL.equalsIgnoreCase(argument)) return null; | else if (pathFieldType.equals(LocalDateTime.class)) return DateUtil.parseLocalDateTime(argument); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageBuilder.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageBuilder.java
// public interface PageBuilder<T, E extends PageParam> {
// T visit(PageNode pageNode, E pageParam);
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
| import com.github.vineey.rql.page.PageBuilder;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.querydsl.core.QueryModifiers; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
public class QuerydslPageBuilder implements PageBuilder<QueryModifiers, QuerydslPageParam> {
@Override | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageBuilder.java
// public interface PageBuilder<T, E extends PageParam> {
// T visit(PageNode pageNode, E pageParam);
// }
//
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
// private Long start;
// private Long size;
//
// public Long getStart() {
// return start;
// }
//
// public PageNode setStart(Long start) {
// this.start = start;
// return this;
// }
//
// public Long getSize() {
// return size;
// }
//
// public PageNode setSize(Long size) {
// this.size = size;
// return this;
// }
//
// }
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageBuilder.java
import com.github.vineey.rql.page.PageBuilder;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.querydsl.core.QueryModifiers;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
public class QuerydslPageBuilder implements PageBuilder<QueryModifiers, QuerydslPageParam> {
@Override | public QueryModifiers visit(PageNode pageNode, QuerydslPageParam pageParam) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_ListPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_ListPath_Test {
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_ListPath_Test.java
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_ListPath_Test {
| private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_ListPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_ListPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Test
public void listNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.names", QEmployee.employee.names)
.build();
String rqlFilter = "employee.names=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_ListPath_Test.java
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.querydsl.test.jpa.QEmployee;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_ListPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Test
public void listNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.names", QEmployee.employee.names)
.build();
String rqlFilter = "employee.names=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | withBuilderAndParam(new QuerydslFilterBuilder(), new QuerydslFilterParam() |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_SetPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_SetPath_Test {
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_SetPath_Test.java
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_SetPath_Test {
| private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_SetPath_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
| import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_SetPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Test
public void setNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameSet", employee.nameSet)
.build();
String rqlFilter = "employee.nameSet=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_SetPath_Test.java
import java.util.Map;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.test.jpa.QEmployee.employee;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.google.common.collect.ImmutableMap;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_SetPath_Test {
private final static DefaultFilterParser DEFAULT_FILTER_PARSER = new DefaultFilterParser();
@Test
public void setNotEmpty() {
Map<String, Path> pathHashMap = ImmutableMap.<String, Path>builder()
.put("employee.nameSet", employee.nameSet)
.build();
String rqlFilter = "employee.nameSet=sizene=0";
Predicate predicate = DEFAULT_FILTER_PARSER.parse(rqlFilter, | withBuilderAndParam(new QuerydslFilterBuilder(), new QuerydslFilterParam() |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/EnumsTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class EnumsTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@BeforeClass
public static void init(){ | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/EnumsTest.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.Month;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class EnumsTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
@BeforeClass
public static void init(){ | new Enums(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
| private final static FilterParser FILTER_PARSER = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
| // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
| private final static FilterParser FILTER_PARSER = new DefaultFilterParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
private final static FilterParser FILTER_PARSER = new DefaultFilterParser();
@Test
public void multipleFilters() {
String rqlFilter = "(name=='Khiel' and birthDate > '2014-05-11') or (name=='Vhia' and birthDate > '2011-09-14')";
Predicate predicate = FILTER_PARSER.parse(rqlFilter, | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
private final static FilterParser FILTER_PARSER = new DefaultFilterParser();
@Test
public void multipleFilters() {
String rqlFilter = "(name=='Khiel' and birthDate > '2014-05-11') or (name=='Vhia' and birthDate > '2011-09-14')";
Predicate predicate = FILTER_PARSER.parse(rqlFilter, | withBuilderAndParam(new QuerydslFilterBuilder(), |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
| import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
private final static FilterParser FILTER_PARSER = new DefaultFilterParser();
@Test
public void multipleFilters() {
String rqlFilter = "(name=='Khiel' and birthDate > '2014-05-11') or (name=='Vhia' and birthDate > '2011-09-14')";
Predicate predicate = FILTER_PARSER.parse(rqlFilter,
withBuilderAndParam(new QuerydslFilterBuilder(), | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
// public class DefaultFilterParser implements FilterParser {
// private RSQLParser rsqlParser;
//
// public DefaultFilterParser() {
// rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
// }
//
// @Override
// public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) {
// E filterParam = filterContext.getFilterParam();
// return filterContext.getFilterBuilder().visit(rsqlParser.parse(rqlFilter), filterParam);
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/FilterParser.java
// public interface FilterParser {
// <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext);
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/FilterAssertUtil.java
// public static <T extends Map.Entry<String, Class>> QuerydslFilterParam withFilterParam(T... pathMappings) {
// return withFilterParam(ImmutableList.copyOf(pathMappings));
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/filter/QuerydslFilterBuilder_Multiple_Test.java
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List;
import static com.github.vineey.rql.filter.FilterContext.withBuilderAndParam;
import static com.github.vineey.rql.querydsl.util.FilterAssertUtil.withFilterParam;
import static org.junit.Assert.*;
import com.github.vineey.rql.filter.parser.DefaultFilterParser;
import com.github.vineey.rql.filter.parser.FilterParser;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Ops;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.PredicateOperation;
import com.querydsl.core.types.dsl.BooleanOperation;
import org.junit.Assert;
import org.junit.Test;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter;
/**
* @author vrustia - 3/25/16.
*/
@RunWith(JUnit4.class)
public class QuerydslFilterBuilder_Multiple_Test {
private final static FilterParser FILTER_PARSER = new DefaultFilterParser();
@Test
public void multipleFilters() {
String rqlFilter = "(name=='Khiel' and birthDate > '2014-05-11') or (name=='Vhia' and birthDate > '2011-09-14')";
Predicate predicate = FILTER_PARSER.parse(rqlFilter,
withBuilderAndParam(new QuerydslFilterBuilder(), | withFilterParam(new LinkedHashMap.SimpleEntry<>("name", String.class), |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
| import com.github.vineey.rql.core.util.StringUtils;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import cz.jirutka.rsql.parser.ast.RSQLOperators; | public static String build(String selector, ComparisonOperator op, String... args) {
validateArgument(args);
if (singleArgOps.contains(op)) {
return selector + op.getSymbol() + args[0];
} else {
return selector + op.getSymbol() + buildArguments(args);
}
}
public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
validateArgument(args);
String[] rqlFilters = new String[op.getSymbols().length];
int index = 0;
for (String symbol : op.getSymbols()) {
if (singleArgOps.contains(op)) {
rqlFilters[index] = selector + symbol + args[0];
} else {
rqlFilters[index] = selector + symbol + buildArguments(args);
}
index++;
}
return rqlFilters;
}
private static void validateArgument(String[] args) {
Preconditions.checkNotNull(args);
Preconditions.checkArgument(args.length > 0);
for (String arg : args) { | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/StringUtils.java
// public class StringUtils {
// public static boolean isEmpty(String time) {
// return time == null || time.isEmpty();
// }
//
// public static boolean isNotEmpty(String time) {
// return !isEmpty(time);
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
import com.github.vineey.rql.core.util.StringUtils;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import cz.jirutka.rsql.parser.ast.RSQLOperators;
public static String build(String selector, ComparisonOperator op, String... args) {
validateArgument(args);
if (singleArgOps.contains(op)) {
return selector + op.getSymbol() + args[0];
} else {
return selector + op.getSymbol() + buildArguments(args);
}
}
public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
validateArgument(args);
String[] rqlFilters = new String[op.getSymbols().length];
int index = 0;
for (String symbol : op.getSymbols()) {
if (singleArgOps.contains(op)) {
rqlFilters[index] = selector + symbol + args[0];
} else {
rqlFilters[index] = selector + symbol + buildArguments(args);
}
index++;
}
return rqlFilters;
}
private static void validateArgument(String[] args) {
Preconditions.checkNotNull(args);
Preconditions.checkArgument(args.length > 0);
for (String arg : args) { | Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!"); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/exception/SelectParsingException.java
// public class SelectParsingException extends RuntimeException {
// public SelectParsingException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.github.vineey.rql.select.parser.exception.SelectParsingException;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser.ast;
/**
* @author vrustia - 5/7/16.
*/
public class SelectTokenParserAdapter {
public SelectNodeList parse(String sortExpression) {
try {
return new SelectNodeList(createParser(sortExpression).parse());
} catch (ParseException | Error e) { | // Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/exception/SelectParsingException.java
// public class SelectParsingException extends RuntimeException {
// public SelectParsingException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: rsql-api-parent/rsql-api-select/src/main/java/com/github/vineey/rql/select/parser/ast/SelectTokenParserAdapter.java
import com.github.vineey.rql.select.parser.exception.SelectParsingException;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.select.parser.ast;
/**
* @author vrustia - 5/7/16.
*/
public class SelectTokenParserAdapter {
public SelectNodeList parse(String sortExpression) {
try {
return new SelectNodeList(createParser(sortExpression).parse());
} catch (ParseException | Error e) { | throw new SelectParsingException(e); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/EnumPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
| import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.EnumPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.ArrayList;
import java.util.List; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class EnumPathConverter implements PathConverter<EnumPath> {
@Override
public BooleanExpression evaluate(EnumPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
List<Enum> enumArgs = convertArgumentsToEnum(path, arguments);
Enum firstEnumArg = enumArgs.get(0);
boolean firstArgEqualsNull = firstEnumArg == null;
if (EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNull() : path.eq(firstEnumArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNotNull() : path.ne(firstEnumArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(enumArgs);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(enumArgs);
} | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/EnumPathConverter.java
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.EnumPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.ArrayList;
import java.util.List;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class EnumPathConverter implements PathConverter<EnumPath> {
@Override
public BooleanExpression evaluate(EnumPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
List<Enum> enumArgs = convertArgumentsToEnum(path, arguments);
Enum firstEnumArg = enumArgs.get(0);
boolean firstArgEqualsNull = firstEnumArg == null;
if (EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNull() : path.eq(firstEnumArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNotNull() : path.ne(firstEnumArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(enumArgs);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(enumArgs);
} | throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/EnumPathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
| import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.EnumPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.ArrayList;
import java.util.List; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class EnumPathConverter implements PathConverter<EnumPath> {
@Override
public BooleanExpression evaluate(EnumPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
List<Enum> enumArgs = convertArgumentsToEnum(path, arguments);
Enum firstEnumArg = enumArgs.get(0);
boolean firstArgEqualsNull = firstEnumArg == null;
if (EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNull() : path.eq(firstEnumArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNotNull() : path.ne(firstEnumArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(enumArgs);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(enumArgs);
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private List<Enum> convertArgumentsToEnum(EnumPath path, List<String> arguments) {
List<Enum> enumArgs = new ArrayList<>();
if (arguments.size() > 0) {
for (String argument : arguments) {
boolean equalsNullConstant = ConverterConstant.NULL.equalsIgnoreCase(argument); | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/Enums.java
// public final class Enums {
// public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String enumName) {
// if (enumName == null) {
// return null;
// }
// try {
// return Enum.valueOf(enumClass, enumName);
// } catch (IllegalArgumentException e) {
// throw new IllegalArgumentException("Nonexisting enum value of " + enumClass.getSimpleName() + " for ["+enumName+"]");
// }
//
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/EnumPathConverter.java
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.github.vineey.rql.querydsl.filter.util.Enums;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.EnumPath;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.ArrayList;
import java.util.List;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 9/26/2015.
*/
public class EnumPathConverter implements PathConverter<EnumPath> {
@Override
public BooleanExpression evaluate(EnumPath path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
List<Enum> enumArgs = convertArgumentsToEnum(path, arguments);
Enum firstEnumArg = enumArgs.get(0);
boolean firstArgEqualsNull = firstEnumArg == null;
if (EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNull() : path.eq(firstEnumArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstArgEqualsNull ? path.isNotNull() : path.ne(firstEnumArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(enumArgs);
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(enumArgs);
}
throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass());
}
private List<Enum> convertArgumentsToEnum(EnumPath path, List<String> arguments) {
List<Enum> enumArgs = new ArrayList<>();
if (arguments.size() > 0) {
for (String argument : arguments) {
boolean equalsNullConstant = ConverterConstant.NULL.equalsIgnoreCase(argument); | Enum enumArg = equalsNullConstant ? null : Enums.getEnum(path.getType(), argument); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
| import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() { | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() { | rsqlParser = new RSQLParser(QRSQLOperators.getOperators()); |
vineey/archelix-rsql | rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
| import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() {
rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
}
@Override | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() {
rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
}
@Override | public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) { |
vineey/archelix-rsql | rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
| import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() {
rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
}
@Override | // Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterContext.java
// public class FilterContext<T, E extends FilterParam> {
// private FilterBuilder<T, E> filterBuilder;
// private E filterParam;
//
// public static <T, E extends FilterParam> FilterContext<T, E> withBuilderAndParam(FilterBuilder<T, E> builder, E filterParam) {
// return new FilterContext<T, E>()
// .setFilterBuilder(builder)
// .setFilterParam(filterParam);
// }
//
// public FilterBuilder<T, E> getFilterBuilder() {
// return filterBuilder;
// }
//
// public FilterContext setFilterBuilder(FilterBuilder<T, E> filterBuilder) {
// this.filterBuilder = filterBuilder;
// return this;
// }
//
// public E getFilterParam() {
// return filterParam;
// }
//
// public FilterContext setFilterParam(E filterParam) {
// this.filterParam = filterParam;
// return this;
// }
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/FilterParam.java
// public class FilterParam {
// }
//
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/operator/QRSQLOperators.java
// public final class QRSQLOperators {
// public static final ComparisonOperator SIZE_EQ = new ComparisonOperator("=size=");
// public static final ComparisonOperator SIZE_NOT_EQ = new ComparisonOperator("=sizene=");
// private final static Logger LOGGER = LoggerFactory.getLogger(QRSQLOperators.class);
//
// public static Set<ComparisonOperator> getOperators() {
// Set<ComparisonOperator> comparisonOperators = RSQLOperators.defaultOperators();
// comparisonOperators.addAll(Arrays.asList(SIZE_EQ, SIZE_NOT_EQ));
//
// LOGGER.debug("Default Rsql Operators : {}", Arrays.toString(comparisonOperators.toArray(new ComparisonOperator[]{})));
//
// return comparisonOperators;
// }
// }
// Path: rsql-api-parent/rsql-api-filter/src/main/java/com/github/vineey/rql/filter/parser/DefaultFilterParser.java
import com.github.vineey.rql.filter.FilterParam;
import com.github.vineey.rql.filter.operator.QRSQLOperators;
import cz.jirutka.rsql.parser.RSQLParser;
import com.github.vineey.rql.filter.FilterContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.filter.parser;
/**
* @author vrustia on 9/20/2015.
*/
public class DefaultFilterParser implements FilterParser {
private RSQLParser rsqlParser;
public DefaultFilterParser() {
rsqlParser = new RSQLParser(QRSQLOperators.getOperators());
}
@Override | public <T, E extends FilterParam> T parse(String rqlFilter, FilterContext<T, E> filterContext) { |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/RSQLUtilTest.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
| import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class RSQLUtilTest {
@BeforeClass
public static void init(){ | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/util/RSQLUtil.java
// public final class RSQLUtil {
// private final static ImmutableList<ComparisonOperator> singleArgOps = ImmutableList.<ComparisonOperator>builder()
// .add(RSQLOperators.EQUAL,
// RSQLOperators.NOT_EQUAL,
// RSQLOperators.GREATER_THAN,
// RSQLOperators.GREATER_THAN_OR_EQUAL,
// RSQLOperators.LESS_THAN,
// RSQLOperators.LESS_THAN_OR_EQUAL)
// .build();
//
// public static String build(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// if (singleArgOps.contains(op)) {
// return selector + op.getSymbol() + args[0];
// } else {
// return selector + op.getSymbol() + buildArguments(args);
// }
// }
//
// public static String[] buildAllSymbols(String selector, ComparisonOperator op, String... args) {
// validateArgument(args);
// String[] rqlFilters = new String[op.getSymbols().length];
//
// int index = 0;
// for (String symbol : op.getSymbols()) {
// if (singleArgOps.contains(op)) {
// rqlFilters[index] = selector + symbol + args[0];
// } else {
// rqlFilters[index] = selector + symbol + buildArguments(args);
// }
// index++;
// }
//
// return rqlFilters;
// }
//
// private static void validateArgument(String[] args) {
// Preconditions.checkNotNull(args);
// Preconditions.checkArgument(args.length > 0);
// for (String arg : args) {
// Preconditions.checkArgument(StringUtils.isNotEmpty(arg), "Argument should not be empty!");
// }
// }
//
// public static String buildArguments(String... args) {
// return "(" + Joiner.on(",").join(args) + ")";
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/RSQLUtilTest.java
import com.github.vineey.rql.querydsl.filter.util.RSQLUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class RSQLUtilTest {
@BeforeClass
public static void init(){ | new RSQLUtil(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/CollectionUtilTest.java | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
| import org.junit.runners.JUnit4;
import java.util.ArrayList;
import com.github.vineey.rql.core.util.CollectionUtils;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class CollectionUtilTest {
@BeforeClass
public static void init(){ | // Path: rsql-api-parent/rsql-api-core/src/main/java/com/github/vineey/rql/core/util/CollectionUtils.java
// public class CollectionUtils {
// public static boolean isNotEmpty(Collection collection) {
// return !isEmpty(collection);
// }
//
// public static boolean isEmpty(Collection collection) {
// return collection == null || collection.isEmpty();
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/test/java/com/github/vineey/rql/querydsl/util/CollectionUtilTest.java
import org.junit.runners.JUnit4;
import java.util.ArrayList;
import com.github.vineey.rql.core.util.CollectionUtils;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.util;
/**
* @author vrustia - 4/17/16.
*/
@RunWith(JUnit4.class)
public class CollectionUtilTest {
@BeforeClass
public static void init(){ | new CollectionUtils(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-page/src/test/java/com/github/vineey/rql/querydsl/page/QuerydslPageContextTest.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
| import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslPageContextTest {
@Test
public void parseLimit() { | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/test/java/com/github/vineey/rql/querydsl/page/QuerydslPageContextTest.java
import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslPageContextTest {
@Test
public void parseLimit() { | DefaultPageParser defaultPageParser = new DefaultPageParser(); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-page/src/test/java/com/github/vineey/rql/querydsl/page/QuerydslPageContextTest.java | // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
| import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; | /*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslPageContextTest {
@Test
public void parseLimit() {
DefaultPageParser defaultPageParser = new DefaultPageParser();
| // Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
// public class DefaultPageParser implements PageParser {
//
// private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();
//
// @Override
// public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);
// return pageContext.getPageBuilder().visit(parsedPageNode, pageContext.getPageParam());
// }
//
// }
//
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/main/java/com/github/vineey/rql/querydsl/page/QuerydslPageContext.java
// public static QuerydslPageContext withDefault() {
// return withPageParams(new QuerydslPageParam());
// }
// Path: rsql-querydsl-parent/rsql-querydsl-page/src/test/java/com/github/vineey/rql/querydsl/page/QuerydslPageContextTest.java
import static com.github.vineey.rql.querydsl.page.QuerydslPageContext.withDefault;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import com.github.vineey.rql.page.parser.DefaultPageParser;
import com.querydsl.core.QueryModifiers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
package com.github.vineey.rql.querydsl.page;
/**
* @author vrustia - 4/9/16.
*/
@RunWith(JUnit4.class)
public class QuerydslPageContextTest {
@Test
public void parseLimit() {
DefaultPageParser defaultPageParser = new DefaultPageParser();
| QueryModifiers querydslPage = defaultPageParser.parse("limit(10, 5)", withDefault()); |
vineey/archelix-rsql | rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractTimeRangePathConverter.java | // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
| import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.TemporalExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*; | /* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public abstract class AbstractTimeRangePathConverter<RANGE extends Comparable, PATH extends TemporalExpression> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
Comparable firstTimeArg = convertArgument((Class<RANGE>) path.getType(), arguments.get(0));
if (EQUAL.equals(comparisonOperator)) {
return firstTimeArg == null ? path.isNull() : path.eq(firstTimeArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstTimeArg == null ? path.isNotNull() : path.ne(firstTimeArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToArgumentList(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToArgumentList(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstTimeArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstTimeArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstTimeArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstTimeArg);
}
| // Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/UnsupportedRqlOperatorException.java
// public class UnsupportedRqlOperatorException extends UnsupportedOperationException {
// public UnsupportedRqlOperatorException(ComparisonNode comparisonNode, Class<? extends Expression> pathClass) {
// super("The comparison operator within expression [" + comparisonNode.toString() + "] is not supported on type " + pathClass.getSimpleName() + ".");
// }
// }
// Path: rsql-querydsl-parent/rsql-querydsl-filter/src/main/java/com/github/vineey/rql/querydsl/filter/converter/AbstractTimeRangePathConverter.java
import com.github.vineey.rql.querydsl.filter.UnsupportedRqlOperatorException;
import com.google.common.collect.Lists;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.TemporalExpression;
import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.ComparisonOperator;
import java.util.List;
import static cz.jirutka.rsql.parser.ast.RSQLOperators.*;
/* * MIT License
* * Copyright (c) 2016 John Michael Vincent S. Rustia
* * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* * The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * */
package com.github.vineey.rql.querydsl.filter.converter;
/**
* @author vrustia on 10/12/2015.
*/
public abstract class AbstractTimeRangePathConverter<RANGE extends Comparable, PATH extends TemporalExpression> implements PathConverter<PATH> {
@Override
public BooleanExpression evaluate(PATH path, ComparisonNode comparisonNode) {
ComparisonOperator comparisonOperator = comparisonNode.getOperator();
List<String> arguments = comparisonNode.getArguments();
Comparable firstTimeArg = convertArgument((Class<RANGE>) path.getType(), arguments.get(0));
if (EQUAL.equals(comparisonOperator)) {
return firstTimeArg == null ? path.isNull() : path.eq(firstTimeArg);
} else if (NOT_EQUAL.equals(comparisonOperator)) {
return firstTimeArg == null ? path.isNotNull() : path.ne(firstTimeArg);
} else if (IN.equals(comparisonOperator)) {
return path.in(convertToArgumentList(path, arguments));
} else if (NOT_IN.equals(comparisonOperator)) {
return path.notIn(convertToArgumentList(path, arguments));
} else if (GREATER_THAN.equals(comparisonOperator)) {
return path.gt(firstTimeArg);
} else if (GREATER_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.goe(firstTimeArg);
} else if (LESS_THAN.equals(comparisonOperator)) {
return path.lt(firstTimeArg);
} else if (LESS_THAN_OR_EQUAL.equals(comparisonOperator)) {
return path.loe(firstTimeArg);
}
| throw new UnsupportedRqlOperatorException(comparisonNode, path.getClass()); |
shibing624/crf-seg | src/main/java/org/xm/xmnlp/seg/domain/Term.java | // Path: src/main/java/org/xm/xmnlp/Xmnlp.java
// public class Xmnlp {
// /**
// * 日志组件
// */
// private static Logger logger = LogManager.getLogger();
//
// public static final class Config {
// /**
// * 默认关闭调试
// */
// public static boolean DEBUG = false;
// /**
// * 字符类型对应表
// */
// public static String CharTypePath = "data/dictionary/other/CharType.dat.yes";
//
// /**
// * 字符正规化表(全角转半角,繁体转简体)
// */
// public static String CharTablePath = "data/dictionary/other/CharTable.bin.yes";
//
// /**
// * 词频统计输出路径
// */
// public static String StatisticsResultPath = "data/result/WordFrequencyStatistics-Result.txt";
// /**
// * 最大熵-依存关系模型
// */
// public static String MaxEntModelPath = "data/model/dependency/MaxEntModel.txt";
// /**
// * 神经网络依存模型路径
// */
// public static String NNParserModelPath = "data/model/dependency/NNParserModel.txt";
// /**
// * CRF分词模型
// */
// public static String CRFSegmentModelPath = "data/model/seg/CRFSegmentModel.txt";
// /**
// * HMM分词模型
// */
// public static String HMMSegmentModelPath = "data/model/seg/HMMSegmentModel.bin";
// /**
// * CRF依存模型
// */
// public static String CRFDependencyModelPath = "data/model/dependency/CRFDependencyModelMini.txt";
// /**
// * 分词结果是否展示词性
// */
// public static boolean ShowTermNature = true;
// /**
// * 是否执行字符正规化(繁体->简体,全角->半角,大写->小写),切换配置后必须删CustomDictionary.txt.bin缓存
// */
// public static boolean Normalization = false;
//
// static {
// Properties p = new Properties();
// try {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Xmnlp.Config.class.getClassLoader();
// }
// p.load(new InputStreamReader(Static.PROPERTIES_PATH == null ?
// loader.getResourceAsStream("xmnlp.properties")
// : new FileInputStream(Static.PROPERTIES_PATH), "UTF-8"));
// String root = p.getProperty("root", "").replaceAll("\\\\", "/");
// if (!root.endsWith("/")) root += "/";
// String prePath = root;
// MaxEntModelPath = root + p.getProperty("MaxEntModelPath", MaxEntModelPath);
// NNParserModelPath = root + p.getProperty("NNParserModelPath", NNParserModelPath);
// CRFSegmentModelPath = root + p.getProperty("CRFSegmentModelPath", CRFSegmentModelPath);
// CRFDependencyModelPath = root + p.getProperty("CRFDependencyModelPath", CRFDependencyModelPath);
// HMMSegmentModelPath = root + p.getProperty("HMMSegmentModelPath", HMMSegmentModelPath);
// ShowTermNature = "true".equals(p.getProperty("ShowTermNature", "true"));
// Normalization = "true".equals(p.getProperty("Normalization", "false"));
// } catch (Exception e) {
// StringBuilder sb = new StringBuilder("make sure the xmnlp.properties is exist.");
// String classPath = (String) System.getProperties().get("java.class.PATHS");
// if (classPath != null) {
// for (String path : classPath.split(File.pathSeparator)) {
// if (new File(path).isDirectory()) {
// sb.append(path).append('\n');
// }
// }
// }
// sb.append("并且编辑root=PARENT/PATHS/to/your/data\n");
// sb.append("现在Xmnlp将尝试从").append(System.getProperties().get("user.dir")).append("读取data……");
// logger.warn("没有找到xmnlp.properties,可能会导致找不到data\n" + sb);
// }
// }
//
// }
//
// private Xmnlp() {
// }
//
//
// /**
// * CRF分词
// *
// * @param text 文本
// * @return 切分后的单词
// */
// public static List<Term> crfSegment(String text) {
// return new CRFSegment().seg(text);
// }
//
// }
| import org.xm.xmnlp.Xmnlp; | package org.xm.xmnlp.seg.domain;
/**
* Created by xuming on 2016/7/22.
*/
public class Term {
/**
* 词语
*/
public String word;
/**
* 词性
*/
public Nature nature;
/**
* 在文本中的起始位置(需开启分词器的offset选项)
*/
public int offset;
/**
* 长度
*/
public int length() {
return word.length();
}
/**
* 词性
*/
public Nature getNature() {
return nature;
}
public void setNature(Nature nature) {
this.nature = nature;
}
/**
* 构造一个单词
*
* @param word 词语
* @param nature 词性
*/
public Term(String word, Nature nature) {
this.word = word;
this.setNature(nature);
}
@Override
public String toString() { | // Path: src/main/java/org/xm/xmnlp/Xmnlp.java
// public class Xmnlp {
// /**
// * 日志组件
// */
// private static Logger logger = LogManager.getLogger();
//
// public static final class Config {
// /**
// * 默认关闭调试
// */
// public static boolean DEBUG = false;
// /**
// * 字符类型对应表
// */
// public static String CharTypePath = "data/dictionary/other/CharType.dat.yes";
//
// /**
// * 字符正规化表(全角转半角,繁体转简体)
// */
// public static String CharTablePath = "data/dictionary/other/CharTable.bin.yes";
//
// /**
// * 词频统计输出路径
// */
// public static String StatisticsResultPath = "data/result/WordFrequencyStatistics-Result.txt";
// /**
// * 最大熵-依存关系模型
// */
// public static String MaxEntModelPath = "data/model/dependency/MaxEntModel.txt";
// /**
// * 神经网络依存模型路径
// */
// public static String NNParserModelPath = "data/model/dependency/NNParserModel.txt";
// /**
// * CRF分词模型
// */
// public static String CRFSegmentModelPath = "data/model/seg/CRFSegmentModel.txt";
// /**
// * HMM分词模型
// */
// public static String HMMSegmentModelPath = "data/model/seg/HMMSegmentModel.bin";
// /**
// * CRF依存模型
// */
// public static String CRFDependencyModelPath = "data/model/dependency/CRFDependencyModelMini.txt";
// /**
// * 分词结果是否展示词性
// */
// public static boolean ShowTermNature = true;
// /**
// * 是否执行字符正规化(繁体->简体,全角->半角,大写->小写),切换配置后必须删CustomDictionary.txt.bin缓存
// */
// public static boolean Normalization = false;
//
// static {
// Properties p = new Properties();
// try {
// ClassLoader loader = Thread.currentThread().getContextClassLoader();
// if (loader == null) {
// loader = Xmnlp.Config.class.getClassLoader();
// }
// p.load(new InputStreamReader(Static.PROPERTIES_PATH == null ?
// loader.getResourceAsStream("xmnlp.properties")
// : new FileInputStream(Static.PROPERTIES_PATH), "UTF-8"));
// String root = p.getProperty("root", "").replaceAll("\\\\", "/");
// if (!root.endsWith("/")) root += "/";
// String prePath = root;
// MaxEntModelPath = root + p.getProperty("MaxEntModelPath", MaxEntModelPath);
// NNParserModelPath = root + p.getProperty("NNParserModelPath", NNParserModelPath);
// CRFSegmentModelPath = root + p.getProperty("CRFSegmentModelPath", CRFSegmentModelPath);
// CRFDependencyModelPath = root + p.getProperty("CRFDependencyModelPath", CRFDependencyModelPath);
// HMMSegmentModelPath = root + p.getProperty("HMMSegmentModelPath", HMMSegmentModelPath);
// ShowTermNature = "true".equals(p.getProperty("ShowTermNature", "true"));
// Normalization = "true".equals(p.getProperty("Normalization", "false"));
// } catch (Exception e) {
// StringBuilder sb = new StringBuilder("make sure the xmnlp.properties is exist.");
// String classPath = (String) System.getProperties().get("java.class.PATHS");
// if (classPath != null) {
// for (String path : classPath.split(File.pathSeparator)) {
// if (new File(path).isDirectory()) {
// sb.append(path).append('\n');
// }
// }
// }
// sb.append("并且编辑root=PARENT/PATHS/to/your/data\n");
// sb.append("现在Xmnlp将尝试从").append(System.getProperties().get("user.dir")).append("读取data……");
// logger.warn("没有找到xmnlp.properties,可能会导致找不到data\n" + sb);
// }
// }
//
// }
//
// private Xmnlp() {
// }
//
//
// /**
// * CRF分词
// *
// * @param text 文本
// * @return 切分后的单词
// */
// public static List<Term> crfSegment(String text) {
// return new CRFSegment().seg(text);
// }
//
// }
// Path: src/main/java/org/xm/xmnlp/seg/domain/Term.java
import org.xm.xmnlp.Xmnlp;
package org.xm.xmnlp.seg.domain;
/**
* Created by xuming on 2016/7/22.
*/
public class Term {
/**
* 词语
*/
public String word;
/**
* 词性
*/
public Nature nature;
/**
* 在文本中的起始位置(需开启分词器的offset选项)
*/
public int offset;
/**
* 长度
*/
public int length() {
return word.length();
}
/**
* 词性
*/
public Nature getNature() {
return nature;
}
public void setNature(Nature nature) {
this.nature = nature;
}
/**
* 构造一个单词
*
* @param word 词语
* @param nature 词性
*/
public Term(String word, Nature nature) {
this.word = word;
this.setNature(nature);
}
@Override
public String toString() { | if (Xmnlp.Config.ShowTermNature) |
shibing624/crf-seg | src/main/java/org/xm/xmnlp/collection/trie/ITrie.java | // Path: src/main/java/org/xm/xmnlp/dictionary/io/ByteArray.java
// public class ByteArray {
// byte[] bytes;
// int offset;
//
// public ByteArray(byte[] bytes) {
// this.bytes = bytes;
// }
//
// /**
// * 从文件读取一个字节数组
// *
// * @param path
// * @return
// */
// public static ByteArray createByteArray(String path) {
// byte[] bytes = IOUtil.readBytes(path);
// if (bytes == null) return null;
// return new ByteArray(bytes);
// }
//
// /**
// * 获取全部字节
// *
// * @return
// */
// public byte[] getBytes() {
// return bytes;
// }
//
// /**
// * 读取一个int
// *
// * @return
// */
// public int nextInt() {
// int result = ByteUtil.bytesHighFirstToInt(bytes, offset);
// offset += 4;
// return result;
// }
//
// public double nextDouble() {
// double result = ByteUtil.bytesHighFirstToDouble(bytes, offset);
// offset += 8;
// return result;
// }
//
// /**
// * 读取一个char,对应于writeChar
// *
// * @return
// */
// public char nextChar() {
// char result = ByteUtil.bytesHighFirstToChar(bytes, offset);
// offset += 2;
// return result;
// }
//
// /**
// * 读取一个字节
// *
// * @return
// */
// public byte nextByte() {
// return bytes[offset++];
// }
//
// public boolean hasMore() {
// return offset < bytes.length;
// }
//
// /**
// * 读取一个String,注意这个String是双字节版的,在字符之前有一个整型表示长度
// *
// * @return
// */
// public String nextString() {
// char[] buffer = new char[nextInt()];
// for (int i = 0; i < buffer.length; ++i) {
// buffer[i] = nextChar();
// }
// return new String(buffer);
// }
//
// public float nextFloat() {
// float result = ByteUtil.bytesHighFirstToFloat(bytes, offset);
// offset += 4;
// return result;
// }
//
// /**
// * 读取一个无符号短整型
// *
// * @return
// */
// public int nextUnsignedShort() {
// byte a = nextByte();
// byte b = nextByte();
// return (((a & 0xff) << 8) | (b & 0xff));
// }
//
// /**
// * 读取一个UTF字符串
// *
// * @return
// */
// public String nextUTF() {
// int utflen = nextUnsignedShort();
// byte[] bytearr = null;
// char[] chararr = null;
// bytearr = new byte[utflen];
// chararr = new char[utflen];
//
// int c, char2, char3;
// int count = 0;
// int chararr_count = 0;
//
// for (int i = 0; i < utflen; ++i) {
// bytearr[i] = nextByte();
// }
//
// while (count < utflen) {
// c = (int) bytearr[count] & 0xff;
// if (c > 127) break;
// count++;
// chararr[chararr_count++] = (char) c;
// }
//
// while (count < utflen) {
// c = (int) bytearr[count] & 0xff;
// switch (c >> 4) {
// case 0:
// case 1:
// case 2:
// case 3:
// case 4:
// case 5:
// case 6:
// case 7:
// /* 0xxxxxxx*/
// count++;
// chararr[chararr_count++] = (char) c;
// break;
// case 12:
// case 13:
// /* 110x xxxx 10xx xxxx*/
// count += 2;
// if (count > utflen)
// logger.warn("malformed input: partial character at end");
// char2 = (int) bytearr[count - 1];
// if ((char2 & 0xC0) != 0x80)
// logger.warn(
// "malformed input around byte " + count);
// chararr[chararr_count++] = (char) (((c & 0x1F) << 6) |
// (char2 & 0x3F));
// break;
// case 14:
// /* 1110 xxxx 10xx xxxx 10xx xxxx */
// count += 3;
// if (count > utflen)
// logger.warn("malformed input: partial character at end");
// char2 = (int) bytearr[count - 2];
// char3 = (int) bytearr[count - 1];
// if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
// logger.warn(
// "malformed input around byte " + (count - 1));
// chararr[chararr_count++] = (char) (((c & 0x0F) << 12) |
// ((char2 & 0x3F) << 6) |
// ((char3 & 0x3F) << 0));
// break;
// default:
// /* 10xx xxxx, 1111 xxxx */
// logger.warn("malformed input around byte " + count);
// }
// }
// // The number of chars produced may be less than utflen
// return new String(chararr, 0, chararr_count);
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLength() {
// return bytes.length;
// }
// }
| import org.xm.xmnlp.dictionary.io.ByteArray;
import java.io.DataOutputStream;
import java.util.TreeMap; | package org.xm.xmnlp.collection.trie;
/**
* trie树接口
*/
public interface ITrie<V> {
int build(TreeMap<String, V> keyValueMap);
boolean save(DataOutputStream out);
| // Path: src/main/java/org/xm/xmnlp/dictionary/io/ByteArray.java
// public class ByteArray {
// byte[] bytes;
// int offset;
//
// public ByteArray(byte[] bytes) {
// this.bytes = bytes;
// }
//
// /**
// * 从文件读取一个字节数组
// *
// * @param path
// * @return
// */
// public static ByteArray createByteArray(String path) {
// byte[] bytes = IOUtil.readBytes(path);
// if (bytes == null) return null;
// return new ByteArray(bytes);
// }
//
// /**
// * 获取全部字节
// *
// * @return
// */
// public byte[] getBytes() {
// return bytes;
// }
//
// /**
// * 读取一个int
// *
// * @return
// */
// public int nextInt() {
// int result = ByteUtil.bytesHighFirstToInt(bytes, offset);
// offset += 4;
// return result;
// }
//
// public double nextDouble() {
// double result = ByteUtil.bytesHighFirstToDouble(bytes, offset);
// offset += 8;
// return result;
// }
//
// /**
// * 读取一个char,对应于writeChar
// *
// * @return
// */
// public char nextChar() {
// char result = ByteUtil.bytesHighFirstToChar(bytes, offset);
// offset += 2;
// return result;
// }
//
// /**
// * 读取一个字节
// *
// * @return
// */
// public byte nextByte() {
// return bytes[offset++];
// }
//
// public boolean hasMore() {
// return offset < bytes.length;
// }
//
// /**
// * 读取一个String,注意这个String是双字节版的,在字符之前有一个整型表示长度
// *
// * @return
// */
// public String nextString() {
// char[] buffer = new char[nextInt()];
// for (int i = 0; i < buffer.length; ++i) {
// buffer[i] = nextChar();
// }
// return new String(buffer);
// }
//
// public float nextFloat() {
// float result = ByteUtil.bytesHighFirstToFloat(bytes, offset);
// offset += 4;
// return result;
// }
//
// /**
// * 读取一个无符号短整型
// *
// * @return
// */
// public int nextUnsignedShort() {
// byte a = nextByte();
// byte b = nextByte();
// return (((a & 0xff) << 8) | (b & 0xff));
// }
//
// /**
// * 读取一个UTF字符串
// *
// * @return
// */
// public String nextUTF() {
// int utflen = nextUnsignedShort();
// byte[] bytearr = null;
// char[] chararr = null;
// bytearr = new byte[utflen];
// chararr = new char[utflen];
//
// int c, char2, char3;
// int count = 0;
// int chararr_count = 0;
//
// for (int i = 0; i < utflen; ++i) {
// bytearr[i] = nextByte();
// }
//
// while (count < utflen) {
// c = (int) bytearr[count] & 0xff;
// if (c > 127) break;
// count++;
// chararr[chararr_count++] = (char) c;
// }
//
// while (count < utflen) {
// c = (int) bytearr[count] & 0xff;
// switch (c >> 4) {
// case 0:
// case 1:
// case 2:
// case 3:
// case 4:
// case 5:
// case 6:
// case 7:
// /* 0xxxxxxx*/
// count++;
// chararr[chararr_count++] = (char) c;
// break;
// case 12:
// case 13:
// /* 110x xxxx 10xx xxxx*/
// count += 2;
// if (count > utflen)
// logger.warn("malformed input: partial character at end");
// char2 = (int) bytearr[count - 1];
// if ((char2 & 0xC0) != 0x80)
// logger.warn(
// "malformed input around byte " + count);
// chararr[chararr_count++] = (char) (((c & 0x1F) << 6) |
// (char2 & 0x3F));
// break;
// case 14:
// /* 1110 xxxx 10xx xxxx 10xx xxxx */
// count += 3;
// if (count > utflen)
// logger.warn("malformed input: partial character at end");
// char2 = (int) bytearr[count - 2];
// char3 = (int) bytearr[count - 1];
// if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
// logger.warn(
// "malformed input around byte " + (count - 1));
// chararr[chararr_count++] = (char) (((c & 0x0F) << 12) |
// ((char2 & 0x3F) << 6) |
// ((char3 & 0x3F) << 0));
// break;
// default:
// /* 10xx xxxx, 1111 xxxx */
// logger.warn("malformed input around byte " + count);
// }
// }
// // The number of chars produced may be less than utflen
// return new String(chararr, 0, chararr_count);
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLength() {
// return bytes.length;
// }
// }
// Path: src/main/java/org/xm/xmnlp/collection/trie/ITrie.java
import org.xm.xmnlp.dictionary.io.ByteArray;
import java.io.DataOutputStream;
import java.util.TreeMap;
package org.xm.xmnlp.collection.trie;
/**
* trie树接口
*/
public interface ITrie<V> {
int build(TreeMap<String, V> keyValueMap);
boolean save(DataOutputStream out);
| boolean load(ByteArray byteArray, V[] value); |
shibing624/crf-seg | src/main/java/org/xm/xmnlp/corpus/document/Sentence.java | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/WordFactory.java
// public class WordFactory {
// /**
// * 根据参数字符串产生对应的词语
// *
// * @param param
// * @return
// */
// public static IWord create(String param) {
// if (param == null) return null;
// if (param.startsWith("[") && !param.startsWith("[/")) {
// return CompoundWord.create(param);
// } else {
// return Word.create(param);
// }
// }
// }
| import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.WordFactory;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package org.xm.xmnlp.corpus.document;
/**
* 句子,指的是以。,:!结尾的句子
*/
public class Sentence implements Serializable {
private static Logger logger = LogManager.getLogger(); | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/WordFactory.java
// public class WordFactory {
// /**
// * 根据参数字符串产生对应的词语
// *
// * @param param
// * @return
// */
// public static IWord create(String param) {
// if (param == null) return null;
// if (param.startsWith("[") && !param.startsWith("[/")) {
// return CompoundWord.create(param);
// } else {
// return Word.create(param);
// }
// }
// }
// Path: src/main/java/org/xm/xmnlp/corpus/document/Sentence.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.WordFactory;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package org.xm.xmnlp.corpus.document;
/**
* 句子,指的是以。,:!结尾的句子
*/
public class Sentence implements Serializable {
private static Logger logger = LogManager.getLogger(); | public List<IWord> wordList; |
shibing624/crf-seg | src/main/java/org/xm/xmnlp/corpus/document/Sentence.java | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/WordFactory.java
// public class WordFactory {
// /**
// * 根据参数字符串产生对应的词语
// *
// * @param param
// * @return
// */
// public static IWord create(String param) {
// if (param == null) return null;
// if (param.startsWith("[") && !param.startsWith("[/")) {
// return CompoundWord.create(param);
// } else {
// return Word.create(param);
// }
// }
// }
| import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.WordFactory;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package org.xm.xmnlp.corpus.document;
/**
* 句子,指的是以。,:!结尾的句子
*/
public class Sentence implements Serializable {
private static Logger logger = LogManager.getLogger();
public List<IWord> wordList;
public Sentence(List<IWord> wordList) {
this.wordList = wordList;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
int i = 1;
for (IWord word : wordList) {
sb.append(word);
if (i != wordList.size()) sb.append(' ');
++i;
}
return sb.toString();
}
public static Sentence create(String param) {
Pattern pattern = Pattern.compile("(\\[(([^\\s]+/[0-9a-zA-Z]+)\\s+)+?([^\\s]+/[0-9a-zA-Z]+)]/[0-9a-zA-Z]+)|([^\\s]+/[0-9a-zA-Z]+)");
Matcher matcher = pattern.matcher(param);
List<IWord> wordList = new LinkedList<IWord>();
while (matcher.find()) {
String single = matcher.group(); | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/WordFactory.java
// public class WordFactory {
// /**
// * 根据参数字符串产生对应的词语
// *
// * @param param
// * @return
// */
// public static IWord create(String param) {
// if (param == null) return null;
// if (param.startsWith("[") && !param.startsWith("[/")) {
// return CompoundWord.create(param);
// } else {
// return Word.create(param);
// }
// }
// }
// Path: src/main/java/org/xm/xmnlp/corpus/document/Sentence.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.WordFactory;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package org.xm.xmnlp.corpus.document;
/**
* 句子,指的是以。,:!结尾的句子
*/
public class Sentence implements Serializable {
private static Logger logger = LogManager.getLogger();
public List<IWord> wordList;
public Sentence(List<IWord> wordList) {
this.wordList = wordList;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
int i = 1;
for (IWord word : wordList) {
sb.append(word);
if (i != wordList.size()) sb.append(' ');
++i;
}
return sb.toString();
}
public static Sentence create(String param) {
Pattern pattern = Pattern.compile("(\\[(([^\\s]+/[0-9a-zA-Z]+)\\s+)+?([^\\s]+/[0-9a-zA-Z]+)]/[0-9a-zA-Z]+)|([^\\s]+/[0-9a-zA-Z]+)");
Matcher matcher = pattern.matcher(param);
List<IWord> wordList = new LinkedList<IWord>();
while (matcher.find()) {
String single = matcher.group(); | IWord word = WordFactory.create(single); |
shibing624/crf-seg | src/main/java/org/xm/xmnlp/corpus/document/Document.java | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/CompoundWord.java
// public class CompoundWord implements IWord {
// private static Logger logger = LogManager.getLogger();
// /**
// * 由这些词复合而来
// */
// public List<Word> innerList;
//
// public String label;
//
// @Override
// public String getValue() {
// StringBuilder sb = new StringBuilder();
// for (Word word : innerList) {
// sb.append(word.value);
// }
// return sb.toString();
// }
//
// @Override
// public String getLabel() {
// return label;
// }
//
// @Override
// public void setLabel(String label) {
// this.label = label;
// }
//
// @Override
// public void setValue(String value) {
// innerList.clear();
// innerList.add(new Word(value, label));
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append('[');
// int i = 1;
// for (Word word : innerList) {
// sb.append(word.toString());
// if (i != innerList.size()) {
// sb.append(' ');
// }
// ++i;
// }
// sb.append("]/");
// sb.append(label);
// return sb.toString();
// }
//
// /**
// * 转换为一个简单词
// *
// * @return
// */
// public Word toWord() {
// return new Word(getValue(), getLabel());
// }
//
// public CompoundWord(List<Word> innerList, String label) {
// this.innerList = innerList;
// this.label = label;
// }
//
// public static CompoundWord create(String param) {
// if (param == null) return null;
// int cutIndex = param.lastIndexOf('/');
// if (cutIndex <= 2 || cutIndex == param.length() - 1) return null;
// String wordParam = param.substring(1, cutIndex - 1);
// List<Word> wordList = new LinkedList<Word>();
// for (String single : wordParam.split(" ")) {
// if (single.length() == 0) continue;
// Word word = Word.create(single);
// if (word == null) {
// logger.warn("使用参数" + single + "构造单词时发生错误");
// return null;
// }
// wordList.add(word);
// }
// String labelParam = param.substring(cutIndex + 1);
// return new CompoundWord(wordList, labelParam);
// }
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/Word.java
// public class Word implements IWord {
// private static Logger logger = LogManager.getLogger();
// /**
// * 单词的真实值,比如“程序”
// */
// public String value;
// /**
// * 单词的标签,比如“n”
// */
// public String label;
//
// @Override
// public String toString() {
// return value + '/' + label;
// }
//
// public Word(String value, String label) {
// this.value = value;
// this.label = label;
// }
//
// /**
// * 通过参数构造一个单词
// *
// * @param param 比如 人民网/nz
// * @return 一个单词
// */
// public static Word create(String param) {
// if (param == null) return null;
// int cutIndex = param.lastIndexOf('/');
// if (cutIndex <= 0 || cutIndex == param.length() - 1) {
// logger.warn("使用 " + param + "创建单个单词失败");
// return null;
// }
//
// return new Word(param.substring(0, cutIndex), param.substring(cutIndex + 1));
// }
//
// @Override
// public String getValue() {
// return value;
// }
//
// @Override
// public String getLabel() {
// return label;
// }
//
// @Override
// public void setLabel(String label) {
// this.label = label;
// }
//
// @Override
// public void setValue(String value) {
// this.value = value;
// }
// }
| import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.CompoundWord;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.Word;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | List<Sentence> sentenceList = new LinkedList<Sentence>();
while (matcher.find()) {
String single = matcher.group();
Sentence sentence = Sentence.create(single);
if (sentence == null) {
logger.warn("使用" + single + "构建句子失败");
return null;
}
sentenceList.add(sentence);
}
return new Document(sentenceList);
}
/**
* 获取单词序列
*
* @return
*/
public List<IWord> getWordList() {
List<IWord> wordList = new LinkedList<IWord>();
for (Sentence sentence : sentenceList) {
wordList.addAll(sentence.wordList);
}
return wordList;
}
public List<Word> getSimpleWordList() {
List<IWord> wordList = getWordList();
List<Word> simpleWordList = new LinkedList<Word>();
for (IWord word : wordList) { | // Path: src/main/java/org/xm/xmnlp/corpus/document/word/CompoundWord.java
// public class CompoundWord implements IWord {
// private static Logger logger = LogManager.getLogger();
// /**
// * 由这些词复合而来
// */
// public List<Word> innerList;
//
// public String label;
//
// @Override
// public String getValue() {
// StringBuilder sb = new StringBuilder();
// for (Word word : innerList) {
// sb.append(word.value);
// }
// return sb.toString();
// }
//
// @Override
// public String getLabel() {
// return label;
// }
//
// @Override
// public void setLabel(String label) {
// this.label = label;
// }
//
// @Override
// public void setValue(String value) {
// innerList.clear();
// innerList.add(new Word(value, label));
// }
//
// @Override
// public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append('[');
// int i = 1;
// for (Word word : innerList) {
// sb.append(word.toString());
// if (i != innerList.size()) {
// sb.append(' ');
// }
// ++i;
// }
// sb.append("]/");
// sb.append(label);
// return sb.toString();
// }
//
// /**
// * 转换为一个简单词
// *
// * @return
// */
// public Word toWord() {
// return new Word(getValue(), getLabel());
// }
//
// public CompoundWord(List<Word> innerList, String label) {
// this.innerList = innerList;
// this.label = label;
// }
//
// public static CompoundWord create(String param) {
// if (param == null) return null;
// int cutIndex = param.lastIndexOf('/');
// if (cutIndex <= 2 || cutIndex == param.length() - 1) return null;
// String wordParam = param.substring(1, cutIndex - 1);
// List<Word> wordList = new LinkedList<Word>();
// for (String single : wordParam.split(" ")) {
// if (single.length() == 0) continue;
// Word word = Word.create(single);
// if (word == null) {
// logger.warn("使用参数" + single + "构造单词时发生错误");
// return null;
// }
// wordList.add(word);
// }
// String labelParam = param.substring(cutIndex + 1);
// return new CompoundWord(wordList, labelParam);
// }
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/IWord.java
// public interface IWord extends Serializable {
// String getValue();
//
// String getLabel();
//
// void setLabel(String label);
//
// void setValue(String value);
// }
//
// Path: src/main/java/org/xm/xmnlp/corpus/document/word/Word.java
// public class Word implements IWord {
// private static Logger logger = LogManager.getLogger();
// /**
// * 单词的真实值,比如“程序”
// */
// public String value;
// /**
// * 单词的标签,比如“n”
// */
// public String label;
//
// @Override
// public String toString() {
// return value + '/' + label;
// }
//
// public Word(String value, String label) {
// this.value = value;
// this.label = label;
// }
//
// /**
// * 通过参数构造一个单词
// *
// * @param param 比如 人民网/nz
// * @return 一个单词
// */
// public static Word create(String param) {
// if (param == null) return null;
// int cutIndex = param.lastIndexOf('/');
// if (cutIndex <= 0 || cutIndex == param.length() - 1) {
// logger.warn("使用 " + param + "创建单个单词失败");
// return null;
// }
//
// return new Word(param.substring(0, cutIndex), param.substring(cutIndex + 1));
// }
//
// @Override
// public String getValue() {
// return value;
// }
//
// @Override
// public String getLabel() {
// return label;
// }
//
// @Override
// public void setLabel(String label) {
// this.label = label;
// }
//
// @Override
// public void setValue(String value) {
// this.value = value;
// }
// }
// Path: src/main/java/org/xm/xmnlp/corpus/document/Document.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.xm.xmnlp.corpus.document.word.CompoundWord;
import org.xm.xmnlp.corpus.document.word.IWord;
import org.xm.xmnlp.corpus.document.word.Word;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
List<Sentence> sentenceList = new LinkedList<Sentence>();
while (matcher.find()) {
String single = matcher.group();
Sentence sentence = Sentence.create(single);
if (sentence == null) {
logger.warn("使用" + single + "构建句子失败");
return null;
}
sentenceList.add(sentence);
}
return new Document(sentenceList);
}
/**
* 获取单词序列
*
* @return
*/
public List<IWord> getWordList() {
List<IWord> wordList = new LinkedList<IWord>();
for (Sentence sentence : sentenceList) {
wordList.addAll(sentence.wordList);
}
return wordList;
}
public List<Word> getSimpleWordList() {
List<IWord> wordList = getWordList();
List<Word> simpleWordList = new LinkedList<Word>();
for (IWord word : wordList) { | if (word instanceof CompoundWord) { |
wangjiegulu/RapidRouter | app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
| import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap; | package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
// Path: app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap;
package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override | public HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper) { |
wangjiegulu/RapidRouter | app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
| import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap; | package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override
public HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper) {
HashMap<String, Class> params;
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class); | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
// Path: app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap;
package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override
public HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper) {
HashMap<String, Class> params;
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class); | getEnsureMap(routerMapper, "rr").put("rapidrouter.a", new RouterTarget(AActivity.class, params)); |
wangjiegulu/RapidRouter | app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
| import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap; | package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override
public HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper) {
HashMap<String, Class> params;
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class);
getEnsureMap(routerMapper, "rr").put("rapidrouter.a", new RouterTarget(AActivity.class, params));
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class);
getEnsureMap(routerMapper, "rr").put("rapidrouter_extra.a", new RouterTarget(AActivity.class, params));
// com.wangjie.rapidrouter.example.activity.BActivity
params = new HashMap<>();
params.put("id", long.class); | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/AActivity.java
// @RRouter(
// {
// @RRUri(uri = "rr://rapidrouter.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// ),
// @RRUri(uri = "rr://rapidrouter_extra.a",
// params = {
// @RRParam(name = "p_name"),
// @RRParam(name = "p_age", type = int.class)
// }
// )
// }
// )
// public class AActivity extends BaseActivity {
//
// private static final String TAG = AActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffaabbcc));
//
// Intent intent = getIntent();
//
// Log.i(TAG, "p_age: " + intent.getIntExtra("p_age", -1) + ", p_name: " + intent.getStringExtra("p_name"));
//
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/BActivity.java
// @RRUri(uri = "rr://rapidrouter.b", params = {
// @RRParam(name = "id", type = long.class)
// })
// public class BActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffbbccaa));
// Intent intent = getIntent();
// Log.i(TAG, "intent: " + intent.getLongExtra("id", -1L));
// }
// }
//
// Path: app/src/main/java/com/wangjie/rapidrouter/example/activity/CActivity.java
// @RRUri(uri = "~((rr)|(sc))://wang.*jie\\.[cx].*", params = {
// @RRParam(name = "paramOfCActivity", type = float.class)
// })
// public class CActivity extends BaseActivity {
// private static final String TAG = BActivity.class.getSimpleName();
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// getWindow().setBackgroundDrawable(new ColorDrawable(0xffccaabb));
// // "adsb".matches("~((rr)|(sc))://wang.*jie\\.[cx].*");
// Log.i(TAG, "paramOfCActivity: " + getIntent().getFloatExtra("paramOfCActivity", -1L));
// }
// }
// Path: app/src/main/java/com/wangjie/rapidrouter/example/ThisRapidRouterMapping.java
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import com.wangjie.rapidrouter.example.activity.AActivity;
import com.wangjie.rapidrouter.example.activity.BActivity;
import com.wangjie.rapidrouter.example.activity.CActivity;
import java.util.HashMap;
package com.wangjie.rapidrouter.example;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisRapidRouterMapping extends RapidRouterMapping {
@Override
public HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper) {
HashMap<String, Class> params;
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class);
getEnsureMap(routerMapper, "rr").put("rapidrouter.a", new RouterTarget(AActivity.class, params));
// com.wangjie.rapidrouter.example.activity.AActivity
params = new HashMap<>();
params.put("p_name", String.class);
params.put("p_age", int.class);
getEnsureMap(routerMapper, "rr").put("rapidrouter_extra.a", new RouterTarget(AActivity.class, params));
// com.wangjie.rapidrouter.example.activity.BActivity
params = new HashMap<>();
params.put("id", long.class); | getEnsureMap(routerMapper, "rr").put("rapidrouter.b", new RouterTarget(BActivity.class, params)); |
wangjiegulu/RapidRouter | library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/base/BaseAbstractProcessor.java | // Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/GlobalEnvironment.java
// public class GlobalEnvironment {
// private static ProcessingEnvironment processingEnv;
//
// public static void init(ProcessingEnvironment processingEnv){
// GlobalEnvironment.processingEnv = processingEnv;
// }
// public static ProcessingEnvironment getProcessingEnv() {
// return processingEnv;
// }
// }
//
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
// public static final boolean LOG_CONTROL = true;
// public static final boolean LOG_FILE = false;
// private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
//
//
// public static void loggerE(Throwable throwable) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// logger("[ERROR]" + transformStackTrace(throwable));
// }
//
// public static void logger(String str) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
// String log = loggerDate + ": " + str;
// if (LOG_CONTROL) {
// GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
// }
// if (LOG_FILE) {
// writeToDisk(log);
// }
// }
//
// private static void writeToDisk(String log) {
// try {
// File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
// if (!logFile.exists()) {
// logFile.getParentFile().mkdirs();
// logFile.createNewFile();
// }
// FileWriter fw = new FileWriter(logFile, true);
// fw.write(log + "\n\n");
// fw.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static StringBuilder transformStackTrace(StackTraceElement[] elements){
// StringBuilder sb = new StringBuilder();
// for(StackTraceElement element : elements){
// sb.append(element.toString()).append("\r\n");
// }
// return sb;
// }
// public static String transformStackTrace(Throwable throwable){
// if(null == throwable){
// return "throwable is null";
// }
// StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
// for(StackTraceElement element : throwable.getStackTrace()){
// sb.append(element.toString()).append("\r\n");
// }
// return sb.toString();
// }
//
// }
| import com.google.auto.common.MoreElements;
import com.wangjie.rapidrouter.compiler.util.GlobalEnvironment;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types; | package com.wangjie.rapidrouter.compiler.base;
/**
* Author: wangjie
* Email: tiantian.china.2@gmail.com
* Date: 3/15/16.
*/
public abstract class BaseAbstractProcessor extends AbstractProcessor {
protected Elements elementUtils;
protected Types typeUtils;
protected Filer filer;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv); | // Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/GlobalEnvironment.java
// public class GlobalEnvironment {
// private static ProcessingEnvironment processingEnv;
//
// public static void init(ProcessingEnvironment processingEnv){
// GlobalEnvironment.processingEnv = processingEnv;
// }
// public static ProcessingEnvironment getProcessingEnv() {
// return processingEnv;
// }
// }
//
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
// public static final boolean LOG_CONTROL = true;
// public static final boolean LOG_FILE = false;
// private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
//
//
// public static void loggerE(Throwable throwable) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// logger("[ERROR]" + transformStackTrace(throwable));
// }
//
// public static void logger(String str) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
// String log = loggerDate + ": " + str;
// if (LOG_CONTROL) {
// GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
// }
// if (LOG_FILE) {
// writeToDisk(log);
// }
// }
//
// private static void writeToDisk(String log) {
// try {
// File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
// if (!logFile.exists()) {
// logFile.getParentFile().mkdirs();
// logFile.createNewFile();
// }
// FileWriter fw = new FileWriter(logFile, true);
// fw.write(log + "\n\n");
// fw.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static StringBuilder transformStackTrace(StackTraceElement[] elements){
// StringBuilder sb = new StringBuilder();
// for(StackTraceElement element : elements){
// sb.append(element.toString()).append("\r\n");
// }
// return sb;
// }
// public static String transformStackTrace(Throwable throwable){
// if(null == throwable){
// return "throwable is null";
// }
// StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
// for(StackTraceElement element : throwable.getStackTrace()){
// sb.append(element.toString()).append("\r\n");
// }
// return sb.toString();
// }
//
// }
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/base/BaseAbstractProcessor.java
import com.google.auto.common.MoreElements;
import com.wangjie.rapidrouter.compiler.util.GlobalEnvironment;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
package com.wangjie.rapidrouter.compiler.base;
/**
* Author: wangjie
* Email: tiantian.china.2@gmail.com
* Date: 3/15/16.
*/
public abstract class BaseAbstractProcessor extends AbstractProcessor {
protected Elements elementUtils;
protected Types typeUtils;
protected Filer filer;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv); | GlobalEnvironment.init(processingEnv); |
wangjiegulu/RapidRouter | library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/base/BaseAbstractProcessor.java | // Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/GlobalEnvironment.java
// public class GlobalEnvironment {
// private static ProcessingEnvironment processingEnv;
//
// public static void init(ProcessingEnvironment processingEnv){
// GlobalEnvironment.processingEnv = processingEnv;
// }
// public static ProcessingEnvironment getProcessingEnv() {
// return processingEnv;
// }
// }
//
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
// public static final boolean LOG_CONTROL = true;
// public static final boolean LOG_FILE = false;
// private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
//
//
// public static void loggerE(Throwable throwable) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// logger("[ERROR]" + transformStackTrace(throwable));
// }
//
// public static void logger(String str) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
// String log = loggerDate + ": " + str;
// if (LOG_CONTROL) {
// GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
// }
// if (LOG_FILE) {
// writeToDisk(log);
// }
// }
//
// private static void writeToDisk(String log) {
// try {
// File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
// if (!logFile.exists()) {
// logFile.getParentFile().mkdirs();
// logFile.createNewFile();
// }
// FileWriter fw = new FileWriter(logFile, true);
// fw.write(log + "\n\n");
// fw.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static StringBuilder transformStackTrace(StackTraceElement[] elements){
// StringBuilder sb = new StringBuilder();
// for(StackTraceElement element : elements){
// sb.append(element.toString()).append("\r\n");
// }
// return sb;
// }
// public static String transformStackTrace(Throwable throwable){
// if(null == throwable){
// return "throwable is null";
// }
// StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
// for(StackTraceElement element : throwable.getStackTrace()){
// sb.append(element.toString()).append("\r\n");
// }
// return sb.toString();
// }
//
// }
| import com.google.auto.common.MoreElements;
import com.wangjie.rapidrouter.compiler.util.GlobalEnvironment;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types; | package com.wangjie.rapidrouter.compiler.base;
/**
* Author: wangjie
* Email: tiantian.china.2@gmail.com
* Date: 3/15/16.
*/
public abstract class BaseAbstractProcessor extends AbstractProcessor {
protected Elements elementUtils;
protected Types typeUtils;
protected Filer filer;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
GlobalEnvironment.init(processingEnv);
elementUtils = processingEnv.getElementUtils();
typeUtils = processingEnv.getTypeUtils();
filer = processingEnv.getFiler();
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
protected void loggerE(Throwable throwable) { | // Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/GlobalEnvironment.java
// public class GlobalEnvironment {
// private static ProcessingEnvironment processingEnv;
//
// public static void init(ProcessingEnvironment processingEnv){
// GlobalEnvironment.processingEnv = processingEnv;
// }
// public static ProcessingEnvironment getProcessingEnv() {
// return processingEnv;
// }
// }
//
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/util/LogUtil.java
// public class LogUtil {
// public static final boolean LOG_CONTROL = true;
// public static final boolean LOG_FILE = false;
// private static SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss");
//
//
// public static void loggerE(Throwable throwable) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// logger("[ERROR]" + transformStackTrace(throwable));
// }
//
// public static void logger(String str) {
// if (!LOG_CONTROL && !LOG_FILE) {
// return;
// }
// String loggerDate = "...[" + LOGGER_DATE_FORMAT.format(new Date()) + "]";
// String log = loggerDate + ": " + str;
// if (LOG_CONTROL) {
// GlobalEnvironment.getProcessingEnv().getMessager().printMessage(Diagnostic.Kind.NOTE, log);
// }
// if (LOG_FILE) {
// writeToDisk(log);
// }
// }
//
// private static void writeToDisk(String log) {
// try {
// File logFile = new File("/Users/wangjie/Desktop/za/test/rapidorm/processor_http.txt");
// if (!logFile.exists()) {
// logFile.getParentFile().mkdirs();
// logFile.createNewFile();
// }
// FileWriter fw = new FileWriter(logFile, true);
// fw.write(log + "\n\n");
// fw.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static StringBuilder transformStackTrace(StackTraceElement[] elements){
// StringBuilder sb = new StringBuilder();
// for(StackTraceElement element : elements){
// sb.append(element.toString()).append("\r\n");
// }
// return sb;
// }
// public static String transformStackTrace(Throwable throwable){
// if(null == throwable){
// return "throwable is null";
// }
// StringBuilder sb = new StringBuilder(throwable.getMessage()).append("\n");
// for(StackTraceElement element : throwable.getStackTrace()){
// sb.append(element.toString()).append("\r\n");
// }
// return sb.toString();
// }
//
// }
// Path: library-compiler/src/main/java/com/wangjie/rapidrouter/compiler/base/BaseAbstractProcessor.java
import com.google.auto.common.MoreElements;
import com.wangjie.rapidrouter.compiler.util.GlobalEnvironment;
import com.wangjie.rapidrouter.compiler.util.LogUtil;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
package com.wangjie.rapidrouter.compiler.base;
/**
* Author: wangjie
* Email: tiantian.china.2@gmail.com
* Date: 3/15/16.
*/
public abstract class BaseAbstractProcessor extends AbstractProcessor {
protected Elements elementUtils;
protected Types typeUtils;
protected Filer filer;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
GlobalEnvironment.init(processingEnv);
elementUtils = processingEnv.getElementUtils();
typeUtils = processingEnv.getTypeUtils();
filer = processingEnv.getFiler();
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
protected void loggerE(Throwable throwable) { | LogUtil.loggerE(throwable); |
wangjiegulu/RapidRouter | library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategySimple.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
| import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import java.util.HashMap; | package com.wangjie.rapidrouter.core.strategy;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public class RapidRouterStrategySimple extends RapidRouterAbstractStrategy {
/**
* HashMap<{scheme}, HashMap<{host}, {router target}>>
*/
private HashMap<String, HashMap<String, RouterTarget>> mapping;
@Override | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategySimple.java
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
import java.util.HashMap;
package com.wangjie.rapidrouter.core.strategy;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public class RapidRouterStrategySimple extends RapidRouterAbstractStrategy {
/**
* HashMap<{scheme}, HashMap<{host}, {router target}>>
*/
private HashMap<String, HashMap<String, RouterTarget>> mapping;
@Override | public void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings) { |
wangjiegulu/RapidRouter | app/src/main/java/com/wangjie/rapidrouter/example/router/ThisOnRapidRouterListener.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RouterStuff.java
// public class RouterStuff {
// private WeakReference<Context> contextRef;
// private Intent intent;
// private String uriStr;
//
// private RouterErrorCallback error;
// private RouterTargetNotFoundCallback targetNotFound;
// private RouterGoBeforeCallback goBefore;
// private RouterGoAroundCallback goAround;
// private RouterGoAfterCallback goAfter;
//
// private List<Class<? extends RapidRouterStrategy>> supportStrategies;
//
// public RouterStuff intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// @Nullable
// public Context context() {
// return null == contextRef ? null : contextRef.get();
// }
//
// public void setContext(Context context) {
// this.contextRef = new WeakReference<>(context);
// }
//
// public RouterStuff uri(String uriStr) {
// this.uriStr = uriStr;
// return this;
// }
//
// public Intent intent() {
// return intent;
// }
//
// public String uriAsString() {
// return uriStr;
// }
//
// public RouterErrorCallback error() {
// return error;
// }
//
// public RouterStuff error(RouterErrorCallback errorListener) {
// this.error = errorListener;
// return this;
// }
//
// public RouterTargetNotFoundCallback targetNotFound() {
// return targetNotFound;
// }
//
// public RouterStuff targetNotFound(RouterTargetNotFoundCallback targetNotFoundListener) {
// this.targetNotFound = targetNotFoundListener;
// return this;
// }
//
// public RouterGoBeforeCallback goBefore() {
// return goBefore;
// }
//
// public RouterStuff goBefore(RouterGoBeforeCallback goBeforeListener) {
// this.goBefore = goBeforeListener;
// return this;
// }
//
// public RouterGoAroundCallback goAround() {
// return goAround;
// }
//
// public RouterStuff goAround(RouterGoAroundCallback goAroundListener) {
// this.goAround = goAroundListener;
// return this;
// }
//
// public RouterGoAfterCallback goAfter() {
// return goAfter;
// }
//
// public RouterStuff goAfter(RouterGoAfterCallback goAfterListener) {
// this.goAfter = goAfterListener;
// return this;
// }
//
// @SafeVarargs
// public final RouterStuff strategies(Class<? extends RapidRouterStrategy>... strategies) {
// if (null == supportStrategies) {
// supportStrategies = new ArrayList<>();
// }
// supportStrategies.addAll(Arrays.asList(strategies));
// return this;
// }
//
// @Nullable
// public List<Class<? extends RapidRouterStrategy>> strategies() {
// return supportStrategies;
// }
//
// public boolean go() {
// if (null == contextRef) {
// throw new RapidRouterIllegalException("Context can not be null!");
// }
// if (null == uriStr) {
// throw new RapidRouterIllegalException("Uri can not be null!");
// }
// return RapidRouter.to(this);
// }
//
// @Override
// public String toString() {
// return "RouterStuff{" +
// "contextRef=" + contextRef +
// ", intent=" + intent +
// ", uriStr='" + uriStr + '\'' +
// ", error=" + error +
// ", targetNotFound=" + targetNotFound +
// ", goBefore=" + goBefore +
// ", goAround=" + goAround +
// ", goAfter=" + goAfter +
// '}';
// }
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/OnRapidRouterListener.java
// public interface OnRapidRouterListener {
//
// void onRouterError(RouterStuff routerStuff, Throwable throwable);
//
// void onRouterGoAfter(RouterStuff routerStuff);
//
// boolean onRouterGoAround(RouterStuff routerStuff);
//
// void onRouterGoBefore(RouterStuff routerStuff);
//
// void onRouterTargetNotFound(RouterStuff routerStuff);
// }
| import android.util.Log;
import com.wangjie.rapidrouter.core.RouterStuff;
import com.wangjie.rapidrouter.core.listener.OnRapidRouterListener; | package com.wangjie.rapidrouter.example.router;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisOnRapidRouterListener implements OnRapidRouterListener {
private static final String TAG = ThisOnRapidRouterListener.class.getSimpleName();
@Override | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RouterStuff.java
// public class RouterStuff {
// private WeakReference<Context> contextRef;
// private Intent intent;
// private String uriStr;
//
// private RouterErrorCallback error;
// private RouterTargetNotFoundCallback targetNotFound;
// private RouterGoBeforeCallback goBefore;
// private RouterGoAroundCallback goAround;
// private RouterGoAfterCallback goAfter;
//
// private List<Class<? extends RapidRouterStrategy>> supportStrategies;
//
// public RouterStuff intent(Intent intent) {
// this.intent = intent;
// return this;
// }
//
// @Nullable
// public Context context() {
// return null == contextRef ? null : contextRef.get();
// }
//
// public void setContext(Context context) {
// this.contextRef = new WeakReference<>(context);
// }
//
// public RouterStuff uri(String uriStr) {
// this.uriStr = uriStr;
// return this;
// }
//
// public Intent intent() {
// return intent;
// }
//
// public String uriAsString() {
// return uriStr;
// }
//
// public RouterErrorCallback error() {
// return error;
// }
//
// public RouterStuff error(RouterErrorCallback errorListener) {
// this.error = errorListener;
// return this;
// }
//
// public RouterTargetNotFoundCallback targetNotFound() {
// return targetNotFound;
// }
//
// public RouterStuff targetNotFound(RouterTargetNotFoundCallback targetNotFoundListener) {
// this.targetNotFound = targetNotFoundListener;
// return this;
// }
//
// public RouterGoBeforeCallback goBefore() {
// return goBefore;
// }
//
// public RouterStuff goBefore(RouterGoBeforeCallback goBeforeListener) {
// this.goBefore = goBeforeListener;
// return this;
// }
//
// public RouterGoAroundCallback goAround() {
// return goAround;
// }
//
// public RouterStuff goAround(RouterGoAroundCallback goAroundListener) {
// this.goAround = goAroundListener;
// return this;
// }
//
// public RouterGoAfterCallback goAfter() {
// return goAfter;
// }
//
// public RouterStuff goAfter(RouterGoAfterCallback goAfterListener) {
// this.goAfter = goAfterListener;
// return this;
// }
//
// @SafeVarargs
// public final RouterStuff strategies(Class<? extends RapidRouterStrategy>... strategies) {
// if (null == supportStrategies) {
// supportStrategies = new ArrayList<>();
// }
// supportStrategies.addAll(Arrays.asList(strategies));
// return this;
// }
//
// @Nullable
// public List<Class<? extends RapidRouterStrategy>> strategies() {
// return supportStrategies;
// }
//
// public boolean go() {
// if (null == contextRef) {
// throw new RapidRouterIllegalException("Context can not be null!");
// }
// if (null == uriStr) {
// throw new RapidRouterIllegalException("Uri can not be null!");
// }
// return RapidRouter.to(this);
// }
//
// @Override
// public String toString() {
// return "RouterStuff{" +
// "contextRef=" + contextRef +
// ", intent=" + intent +
// ", uriStr='" + uriStr + '\'' +
// ", error=" + error +
// ", targetNotFound=" + targetNotFound +
// ", goBefore=" + goBefore +
// ", goAround=" + goAround +
// ", goAfter=" + goAfter +
// '}';
// }
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/listener/OnRapidRouterListener.java
// public interface OnRapidRouterListener {
//
// void onRouterError(RouterStuff routerStuff, Throwable throwable);
//
// void onRouterGoAfter(RouterStuff routerStuff);
//
// boolean onRouterGoAround(RouterStuff routerStuff);
//
// void onRouterGoBefore(RouterStuff routerStuff);
//
// void onRouterTargetNotFound(RouterStuff routerStuff);
// }
// Path: app/src/main/java/com/wangjie/rapidrouter/example/router/ThisOnRapidRouterListener.java
import android.util.Log;
import com.wangjie.rapidrouter.core.RouterStuff;
import com.wangjie.rapidrouter.core.listener.OnRapidRouterListener;
package com.wangjie.rapidrouter.example.router;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/8/17.
*/
public class ThisOnRapidRouterListener implements OnRapidRouterListener {
private static final String TAG = ThisOnRapidRouterListener.class.getSimpleName();
@Override | public void onRouterTargetNotFound(RouterStuff routerStuff) { |
wangjiegulu/RapidRouter | library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
| import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget; | package com.wangjie.rapidrouter.core.strategy;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public interface RapidRouterStrategy {
void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
@Nullable | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/target/RouterTarget.java
// public class RouterTarget {
// private Class targetClass;
// private HashMap<String, Class> params;
//
// public RouterTarget(Class targetClass, HashMap<String, Class> params) {
// this.targetClass = targetClass;
// this.params = params;
// }
//
// public Class getTargetClass() {
// return targetClass;
// }
//
// public void setTargetClass(Class targetClass) {
// this.targetClass = targetClass;
// }
//
// public HashMap<String, Class> getParams() {
// return params;
// }
//
// public void setParams(HashMap<String, Class> params) {
// this.params = params;
// }
// }
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.target.RouterTarget;
package com.wangjie.rapidrouter.core.strategy;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public interface RapidRouterStrategy {
void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
@Nullable | RouterTarget findRouterTarget(@NonNull Uri uri); |
wangjiegulu/RapidRouter | library/src/main/java/com/wangjie/rapidrouter/core/config/RapidRouterConfiguration.java | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java
// public interface RapidRouterStrategy {
//
// void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
//
// @Nullable
// RouterTarget findRouterTarget(@NonNull Uri uri);
//
// }
| import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.strategy.RapidRouterStrategy; | package com.wangjie.rapidrouter.core.config;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public interface RapidRouterConfiguration {
/**
* 配置路由策略
*/
@NonNull | // Path: library/src/main/java/com/wangjie/rapidrouter/core/RapidRouterMapping.java
// public abstract class RapidRouterMapping {
//
// protected HashMap<String, RouterTarget> getEnsureMap(HashMap<String, HashMap<String, RouterTarget>> routerMapper, String key) {
// HashMap<String, RouterTarget> map = routerMapper.get(key);
// if (null == map) {
// map = new HashMap<>();
// routerMapper.put(key, map);
// }
// return map;
// }
//
// public abstract HashMap<String, HashMap<String, RouterTarget>> calcSimpleRouterMapper(HashMap<String, HashMap<String, RouterTarget>> routerMapper);
//
// public abstract HashMap<String, RouterTarget> calcRegRouterMapper(HashMap<String, RouterTarget> routerMapper);
//
// }
//
// Path: library/src/main/java/com/wangjie/rapidrouter/core/strategy/RapidRouterStrategy.java
// public interface RapidRouterStrategy {
//
// void onRapidRouterMappings(RapidRouterMapping[] rapidRouterMappings);
//
// @Nullable
// RouterTarget findRouterTarget(@NonNull Uri uri);
//
// }
// Path: library/src/main/java/com/wangjie/rapidrouter/core/config/RapidRouterConfiguration.java
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.wangjie.rapidrouter.core.RapidRouterMapping;
import com.wangjie.rapidrouter.core.strategy.RapidRouterStrategy;
package com.wangjie.rapidrouter.core.config;
/**
* Author: wangjie Email: tiantian.china.2@gmail.com Date: 2/10/17.
*/
public interface RapidRouterConfiguration {
/**
* 配置路由策略
*/
@NonNull | RapidRouterStrategy[] configRapidRouterStrategies(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.