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
|
---|---|---|---|---|---|---|
cesquivias/mumbler | lang/src/main/java/mumbler/truffle/node/builtin/list/CdrBuiltinNode.java | // Path: lang/src/main/java/mumbler/truffle/node/builtin/BuiltinNode.java
// @NodeChild(value = "arguments", type = MumblerNode[].class)
// public abstract class BuiltinNode extends MumblerNode {
// public static MumblerFunction createBuiltinFunction(
// MumblerLanguage lang,
// NodeFactory<? extends BuiltinNode> factory,
// VirtualFrame outerFrame) {
// int argumentCount = factory.getExecutionSignature().size();
// MumblerNode[] argumentNodes = new MumblerNode[argumentCount];
// for (int i=0; i<argumentCount; i++) {
// argumentNodes[i] = new ReadArgumentNode(i);
// }
// BuiltinNode node = factory.createNode((Object) argumentNodes);
// return new MumblerFunction(Truffle.getRuntime().createCallTarget(
// new MumblerRootNode(lang, new MumblerNode[] {node},
// new FrameDescriptor())));
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerList.java
// public class MumblerList<T extends Object> implements Iterable<T> {
// public static final MumblerList<?> EMPTY = new MumblerList<>();
//
// private final T car;
// private final MumblerList<T> cdr;
// private final int length;
//
// private MumblerList() {
// this.car = null;
// this.cdr = null;
// this.length = 0;
// }
//
// private MumblerList(T car, MumblerList<T> cdr) {
// this.car = car;
// this.cdr = cdr;
// this.length = cdr.length + 1;
// }
//
// @SafeVarargs
// public static <T> MumblerList<T> list(T... objs) {
// return list(asList(objs));
// }
//
// public static <T> MumblerList<T> list(List<T> objs) {
// @SuppressWarnings("unchecked")
// MumblerList<T> l = (MumblerList<T>) EMPTY;
// for (int i=objs.size()-1; i>=0; i--) {
// l = l.cons(objs.get(i));
// }
// return l;
// }
//
// public MumblerList<T> cons(T node) {
// return new MumblerList<T>(node, this);
// }
//
// public T car() {
// if (this != EMPTY) {
// return this.car;
// }
// throw new MumblerException("Cannot car the empty list");
// }
//
// public MumblerList<T> cdr() {
// if (this != EMPTY) {
// return this.cdr;
// }
// throw new MumblerException("Cannot cdr the empty list");
// }
//
// public long size() {
// return this.length;
// }
//
// @Override
// public Iterator<T> iterator() {
// return new Iterator<T>() {
// private MumblerList<T> l = MumblerList.this;
//
// @Override
// public boolean hasNext() {
// return this.l != EMPTY;
// }
//
// @Override
// public T next() {
// if (this.l == EMPTY) {
// throw new MumblerException("At end of list");
// }
// T car = this.l.car;
// this.l = this.l.cdr;
// return car;
// }
//
// @Override
// public void remove() {
// throw new MumblerException("Iterator is immutable");
// }
// };
// }
//
// @Override
// public boolean equals(Object other) {
// if (!(other instanceof MumblerList)) {
// return false;
// }
// if (this == EMPTY && other == EMPTY) {
// return true;
// }
//
// MumblerList<?> that = (MumblerList<?>) other;
// if (this.cdr == EMPTY && that.cdr != EMPTY) {
// return false;
// }
// return this.car.equals(that.car) && this.cdr.equals(that.cdr);
// }
//
// @Override
// public String toString() {
// if (this == EMPTY) {
// return "()";
// }
//
// StringBuilder b = new StringBuilder("(" + this.car);
// MumblerList<T> rest = this.cdr;
// while (rest != null && rest != EMPTY) {
// b.append(" ");
// b.append(rest.car);
// rest = rest.cdr;
// }
// b.append(")");
// return b.toString();
// }
// }
| import mumbler.truffle.node.builtin.BuiltinNode;
import mumbler.truffle.type.MumblerList;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeInfo; | package mumbler.truffle.node.builtin.list;
@NodeInfo(shortName="cdr")
@GenerateNodeFactory | // Path: lang/src/main/java/mumbler/truffle/node/builtin/BuiltinNode.java
// @NodeChild(value = "arguments", type = MumblerNode[].class)
// public abstract class BuiltinNode extends MumblerNode {
// public static MumblerFunction createBuiltinFunction(
// MumblerLanguage lang,
// NodeFactory<? extends BuiltinNode> factory,
// VirtualFrame outerFrame) {
// int argumentCount = factory.getExecutionSignature().size();
// MumblerNode[] argumentNodes = new MumblerNode[argumentCount];
// for (int i=0; i<argumentCount; i++) {
// argumentNodes[i] = new ReadArgumentNode(i);
// }
// BuiltinNode node = factory.createNode((Object) argumentNodes);
// return new MumblerFunction(Truffle.getRuntime().createCallTarget(
// new MumblerRootNode(lang, new MumblerNode[] {node},
// new FrameDescriptor())));
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerList.java
// public class MumblerList<T extends Object> implements Iterable<T> {
// public static final MumblerList<?> EMPTY = new MumblerList<>();
//
// private final T car;
// private final MumblerList<T> cdr;
// private final int length;
//
// private MumblerList() {
// this.car = null;
// this.cdr = null;
// this.length = 0;
// }
//
// private MumblerList(T car, MumblerList<T> cdr) {
// this.car = car;
// this.cdr = cdr;
// this.length = cdr.length + 1;
// }
//
// @SafeVarargs
// public static <T> MumblerList<T> list(T... objs) {
// return list(asList(objs));
// }
//
// public static <T> MumblerList<T> list(List<T> objs) {
// @SuppressWarnings("unchecked")
// MumblerList<T> l = (MumblerList<T>) EMPTY;
// for (int i=objs.size()-1; i>=0; i--) {
// l = l.cons(objs.get(i));
// }
// return l;
// }
//
// public MumblerList<T> cons(T node) {
// return new MumblerList<T>(node, this);
// }
//
// public T car() {
// if (this != EMPTY) {
// return this.car;
// }
// throw new MumblerException("Cannot car the empty list");
// }
//
// public MumblerList<T> cdr() {
// if (this != EMPTY) {
// return this.cdr;
// }
// throw new MumblerException("Cannot cdr the empty list");
// }
//
// public long size() {
// return this.length;
// }
//
// @Override
// public Iterator<T> iterator() {
// return new Iterator<T>() {
// private MumblerList<T> l = MumblerList.this;
//
// @Override
// public boolean hasNext() {
// return this.l != EMPTY;
// }
//
// @Override
// public T next() {
// if (this.l == EMPTY) {
// throw new MumblerException("At end of list");
// }
// T car = this.l.car;
// this.l = this.l.cdr;
// return car;
// }
//
// @Override
// public void remove() {
// throw new MumblerException("Iterator is immutable");
// }
// };
// }
//
// @Override
// public boolean equals(Object other) {
// if (!(other instanceof MumblerList)) {
// return false;
// }
// if (this == EMPTY && other == EMPTY) {
// return true;
// }
//
// MumblerList<?> that = (MumblerList<?>) other;
// if (this.cdr == EMPTY && that.cdr != EMPTY) {
// return false;
// }
// return this.car.equals(that.car) && this.cdr.equals(that.cdr);
// }
//
// @Override
// public String toString() {
// if (this == EMPTY) {
// return "()";
// }
//
// StringBuilder b = new StringBuilder("(" + this.car);
// MumblerList<T> rest = this.cdr;
// while (rest != null && rest != EMPTY) {
// b.append(" ");
// b.append(rest.car);
// rest = rest.cdr;
// }
// b.append(")");
// return b.toString();
// }
// }
// Path: lang/src/main/java/mumbler/truffle/node/builtin/list/CdrBuiltinNode.java
import mumbler.truffle.node.builtin.BuiltinNode;
import mumbler.truffle.type.MumblerList;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeInfo;
package mumbler.truffle.node.builtin.list;
@NodeInfo(shortName="cdr")
@GenerateNodeFactory | public abstract class CdrBuiltinNode extends BuiltinNode { |
cesquivias/mumbler | lang/src/main/java/mumbler/truffle/node/builtin/list/CdrBuiltinNode.java | // Path: lang/src/main/java/mumbler/truffle/node/builtin/BuiltinNode.java
// @NodeChild(value = "arguments", type = MumblerNode[].class)
// public abstract class BuiltinNode extends MumblerNode {
// public static MumblerFunction createBuiltinFunction(
// MumblerLanguage lang,
// NodeFactory<? extends BuiltinNode> factory,
// VirtualFrame outerFrame) {
// int argumentCount = factory.getExecutionSignature().size();
// MumblerNode[] argumentNodes = new MumblerNode[argumentCount];
// for (int i=0; i<argumentCount; i++) {
// argumentNodes[i] = new ReadArgumentNode(i);
// }
// BuiltinNode node = factory.createNode((Object) argumentNodes);
// return new MumblerFunction(Truffle.getRuntime().createCallTarget(
// new MumblerRootNode(lang, new MumblerNode[] {node},
// new FrameDescriptor())));
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerList.java
// public class MumblerList<T extends Object> implements Iterable<T> {
// public static final MumblerList<?> EMPTY = new MumblerList<>();
//
// private final T car;
// private final MumblerList<T> cdr;
// private final int length;
//
// private MumblerList() {
// this.car = null;
// this.cdr = null;
// this.length = 0;
// }
//
// private MumblerList(T car, MumblerList<T> cdr) {
// this.car = car;
// this.cdr = cdr;
// this.length = cdr.length + 1;
// }
//
// @SafeVarargs
// public static <T> MumblerList<T> list(T... objs) {
// return list(asList(objs));
// }
//
// public static <T> MumblerList<T> list(List<T> objs) {
// @SuppressWarnings("unchecked")
// MumblerList<T> l = (MumblerList<T>) EMPTY;
// for (int i=objs.size()-1; i>=0; i--) {
// l = l.cons(objs.get(i));
// }
// return l;
// }
//
// public MumblerList<T> cons(T node) {
// return new MumblerList<T>(node, this);
// }
//
// public T car() {
// if (this != EMPTY) {
// return this.car;
// }
// throw new MumblerException("Cannot car the empty list");
// }
//
// public MumblerList<T> cdr() {
// if (this != EMPTY) {
// return this.cdr;
// }
// throw new MumblerException("Cannot cdr the empty list");
// }
//
// public long size() {
// return this.length;
// }
//
// @Override
// public Iterator<T> iterator() {
// return new Iterator<T>() {
// private MumblerList<T> l = MumblerList.this;
//
// @Override
// public boolean hasNext() {
// return this.l != EMPTY;
// }
//
// @Override
// public T next() {
// if (this.l == EMPTY) {
// throw new MumblerException("At end of list");
// }
// T car = this.l.car;
// this.l = this.l.cdr;
// return car;
// }
//
// @Override
// public void remove() {
// throw new MumblerException("Iterator is immutable");
// }
// };
// }
//
// @Override
// public boolean equals(Object other) {
// if (!(other instanceof MumblerList)) {
// return false;
// }
// if (this == EMPTY && other == EMPTY) {
// return true;
// }
//
// MumblerList<?> that = (MumblerList<?>) other;
// if (this.cdr == EMPTY && that.cdr != EMPTY) {
// return false;
// }
// return this.car.equals(that.car) && this.cdr.equals(that.cdr);
// }
//
// @Override
// public String toString() {
// if (this == EMPTY) {
// return "()";
// }
//
// StringBuilder b = new StringBuilder("(" + this.car);
// MumblerList<T> rest = this.cdr;
// while (rest != null && rest != EMPTY) {
// b.append(" ");
// b.append(rest.car);
// rest = rest.cdr;
// }
// b.append(")");
// return b.toString();
// }
// }
| import mumbler.truffle.node.builtin.BuiltinNode;
import mumbler.truffle.type.MumblerList;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeInfo; | package mumbler.truffle.node.builtin.list;
@NodeInfo(shortName="cdr")
@GenerateNodeFactory
public abstract class CdrBuiltinNode extends BuiltinNode {
@Specialization | // Path: lang/src/main/java/mumbler/truffle/node/builtin/BuiltinNode.java
// @NodeChild(value = "arguments", type = MumblerNode[].class)
// public abstract class BuiltinNode extends MumblerNode {
// public static MumblerFunction createBuiltinFunction(
// MumblerLanguage lang,
// NodeFactory<? extends BuiltinNode> factory,
// VirtualFrame outerFrame) {
// int argumentCount = factory.getExecutionSignature().size();
// MumblerNode[] argumentNodes = new MumblerNode[argumentCount];
// for (int i=0; i<argumentCount; i++) {
// argumentNodes[i] = new ReadArgumentNode(i);
// }
// BuiltinNode node = factory.createNode((Object) argumentNodes);
// return new MumblerFunction(Truffle.getRuntime().createCallTarget(
// new MumblerRootNode(lang, new MumblerNode[] {node},
// new FrameDescriptor())));
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerList.java
// public class MumblerList<T extends Object> implements Iterable<T> {
// public static final MumblerList<?> EMPTY = new MumblerList<>();
//
// private final T car;
// private final MumblerList<T> cdr;
// private final int length;
//
// private MumblerList() {
// this.car = null;
// this.cdr = null;
// this.length = 0;
// }
//
// private MumblerList(T car, MumblerList<T> cdr) {
// this.car = car;
// this.cdr = cdr;
// this.length = cdr.length + 1;
// }
//
// @SafeVarargs
// public static <T> MumblerList<T> list(T... objs) {
// return list(asList(objs));
// }
//
// public static <T> MumblerList<T> list(List<T> objs) {
// @SuppressWarnings("unchecked")
// MumblerList<T> l = (MumblerList<T>) EMPTY;
// for (int i=objs.size()-1; i>=0; i--) {
// l = l.cons(objs.get(i));
// }
// return l;
// }
//
// public MumblerList<T> cons(T node) {
// return new MumblerList<T>(node, this);
// }
//
// public T car() {
// if (this != EMPTY) {
// return this.car;
// }
// throw new MumblerException("Cannot car the empty list");
// }
//
// public MumblerList<T> cdr() {
// if (this != EMPTY) {
// return this.cdr;
// }
// throw new MumblerException("Cannot cdr the empty list");
// }
//
// public long size() {
// return this.length;
// }
//
// @Override
// public Iterator<T> iterator() {
// return new Iterator<T>() {
// private MumblerList<T> l = MumblerList.this;
//
// @Override
// public boolean hasNext() {
// return this.l != EMPTY;
// }
//
// @Override
// public T next() {
// if (this.l == EMPTY) {
// throw new MumblerException("At end of list");
// }
// T car = this.l.car;
// this.l = this.l.cdr;
// return car;
// }
//
// @Override
// public void remove() {
// throw new MumblerException("Iterator is immutable");
// }
// };
// }
//
// @Override
// public boolean equals(Object other) {
// if (!(other instanceof MumblerList)) {
// return false;
// }
// if (this == EMPTY && other == EMPTY) {
// return true;
// }
//
// MumblerList<?> that = (MumblerList<?>) other;
// if (this.cdr == EMPTY && that.cdr != EMPTY) {
// return false;
// }
// return this.car.equals(that.car) && this.cdr.equals(that.cdr);
// }
//
// @Override
// public String toString() {
// if (this == EMPTY) {
// return "()";
// }
//
// StringBuilder b = new StringBuilder("(" + this.car);
// MumblerList<T> rest = this.cdr;
// while (rest != null && rest != EMPTY) {
// b.append(" ");
// b.append(rest.car);
// rest = rest.cdr;
// }
// b.append(")");
// return b.toString();
// }
// }
// Path: lang/src/main/java/mumbler/truffle/node/builtin/list/CdrBuiltinNode.java
import mumbler.truffle.node.builtin.BuiltinNode;
import mumbler.truffle.type.MumblerList;
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.NodeInfo;
package mumbler.truffle.node.builtin.list;
@NodeInfo(shortName="cdr")
@GenerateNodeFactory
public abstract class CdrBuiltinNode extends BuiltinNode {
@Specialization | protected MumblerList<?> cdr(MumblerList<?> list) { |
cesquivias/mumbler | lang/src/main/java/mumbler/truffle/node/special/QuoteNode.java | // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/node/special/QuoteNode.java
// public enum QuoteKind {
// LONG,
// BOOLEAN,
// STRING,
// SYMBOL,
// LIST
// }
| import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.node.special.QuoteNode.QuoteKind;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeField;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame; | package mumbler.truffle.node.special;
@NodeChild("literalNode")
@NodeField(name = "kind", type = QuoteKind.class) | // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/node/special/QuoteNode.java
// public enum QuoteKind {
// LONG,
// BOOLEAN,
// STRING,
// SYMBOL,
// LIST
// }
// Path: lang/src/main/java/mumbler/truffle/node/special/QuoteNode.java
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.node.special.QuoteNode.QuoteKind;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeField;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
package mumbler.truffle.node.special;
@NodeChild("literalNode")
@NodeField(name = "kind", type = QuoteKind.class) | public abstract class QuoteNode extends MumblerNode { |
cesquivias/mumbler | lang/src/main/java/mumbler/truffle/node/special/LoopNode.java | // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/node/call/InvokeNode.java
// public class InvokeNode extends MumblerNode {
// @Child protected MumblerNode functionNode;
// @Children protected final MumblerNode[] argumentNodes;
// @Child protected DispatchNode dispatchNode;
//
// public InvokeNode(MumblerNode functionNode, MumblerNode[] argumentNodes,
// SourceSection sourceSection) {
// this.functionNode = functionNode;
// this.argumentNodes = argumentNodes;
// this.dispatchNode = new UninitializedDispatchNode();
// setSourceSection(sourceSection);
// }
//
// @Override
// @ExplodeLoop
// public Object execute(VirtualFrame virtualFrame) {
// MumblerFunction function = this.evaluateFunction(virtualFrame);
// CompilerAsserts.compilationConstant(this.argumentNodes.length);
// CompilerAsserts.compilationConstant(this.isTail());
//
// Object[] argumentValues = new Object[this.argumentNodes.length + 1];
// argumentValues[0] = function.getLexicalScope();
// for (int i=0; i<this.argumentNodes.length; i++) {
// argumentValues[i+1] = this.argumentNodes[i].execute(virtualFrame);
// }
//
// return call(virtualFrame, function.callTarget, argumentValues);
// }
//
// protected Object call(VirtualFrame virtualFrame, CallTarget callTarget,
// Object[] arguments) {
// return this.dispatchNode.executeDispatch(virtualFrame,
// callTarget, arguments);
// }
//
// private MumblerFunction evaluateFunction(VirtualFrame virtualFrame) {
// try {
// return this.functionNode.executeMumblerFunction(virtualFrame);
// } catch (UnexpectedResultException e) {
// throw new UnsupportedSpecializationException(this,
// new Node[] {this.functionNode}, e);
// }
// }
//
// @Override
// public String toString() {
// return "(apply " + this.functionNode + " " +
// Arrays.toString(this.argumentNodes) + ")";
// }
// }
| import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.node.call.InvokeNode; | package mumbler.truffle.node.special;
@NodeInfo(shortName = "loop", description = "Repeats the function call forever")
public class LoopNode extends MumblerNode {
@Child private com.oracle.truffle.api.nodes.LoopNode loopNode;
private final String callString;
| // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/node/call/InvokeNode.java
// public class InvokeNode extends MumblerNode {
// @Child protected MumblerNode functionNode;
// @Children protected final MumblerNode[] argumentNodes;
// @Child protected DispatchNode dispatchNode;
//
// public InvokeNode(MumblerNode functionNode, MumblerNode[] argumentNodes,
// SourceSection sourceSection) {
// this.functionNode = functionNode;
// this.argumentNodes = argumentNodes;
// this.dispatchNode = new UninitializedDispatchNode();
// setSourceSection(sourceSection);
// }
//
// @Override
// @ExplodeLoop
// public Object execute(VirtualFrame virtualFrame) {
// MumblerFunction function = this.evaluateFunction(virtualFrame);
// CompilerAsserts.compilationConstant(this.argumentNodes.length);
// CompilerAsserts.compilationConstant(this.isTail());
//
// Object[] argumentValues = new Object[this.argumentNodes.length + 1];
// argumentValues[0] = function.getLexicalScope();
// for (int i=0; i<this.argumentNodes.length; i++) {
// argumentValues[i+1] = this.argumentNodes[i].execute(virtualFrame);
// }
//
// return call(virtualFrame, function.callTarget, argumentValues);
// }
//
// protected Object call(VirtualFrame virtualFrame, CallTarget callTarget,
// Object[] arguments) {
// return this.dispatchNode.executeDispatch(virtualFrame,
// callTarget, arguments);
// }
//
// private MumblerFunction evaluateFunction(VirtualFrame virtualFrame) {
// try {
// return this.functionNode.executeMumblerFunction(virtualFrame);
// } catch (UnexpectedResultException e) {
// throw new UnsupportedSpecializationException(this,
// new Node[] {this.functionNode}, e);
// }
// }
//
// @Override
// public String toString() {
// return "(apply " + this.functionNode + " " +
// Arrays.toString(this.argumentNodes) + ")";
// }
// }
// Path: lang/src/main/java/mumbler/truffle/node/special/LoopNode.java
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.node.call.InvokeNode;
package mumbler.truffle.node.special;
@NodeInfo(shortName = "loop", description = "Repeats the function call forever")
public class LoopNode extends MumblerNode {
@Child private com.oracle.truffle.api.nodes.LoopNode loopNode;
private final String callString;
| public LoopNode(InvokeNode callNode) { |
cesquivias/mumbler | lang/src/main/java/mumbler/truffle/node/literal/LiteralSymbolNode.java | // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/syntax/SymbolSyntax.java
// public class SymbolSyntax extends Syntax<MumblerSymbol> {
// public SymbolSyntax(MumblerSymbol value, SourceSection source) {
// super(value, source);
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerSymbol.java
// public class MumblerSymbol {
// public final String name;
//
// public MumblerSymbol(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
| import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.syntax.SymbolSyntax;
import mumbler.truffle.type.MumblerSymbol;
import com.oracle.truffle.api.frame.VirtualFrame; | package mumbler.truffle.node.literal;
public class LiteralSymbolNode extends MumblerNode {
public final MumblerSymbol symbol;
| // Path: lang/src/main/java/mumbler/truffle/node/MumblerNode.java
// @TypeSystemReference(MumblerTypes.class)
// @NodeInfo(language = "Mumbler Language", description = "The abstract base node for all expressions")
// public abstract class MumblerNode extends Node {
// @CompilationFinal
// private SourceSection sourceSection;
//
// @CompilationFinal
// private boolean isTail = false;
//
// @Override
// public SourceSection getSourceSection() {
// return this.sourceSection;
// }
//
// public void setSourceSection(SourceSection sourceSection) {
// this.sourceSection = sourceSection;
// }
//
// public boolean isTail() {
// return this.isTail;
// }
//
// public void setIsTail() {
// this.isTail = true;
// }
//
// public abstract Object execute(VirtualFrame virtualFrame);
//
// public long executeLong(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectLong(this.execute(virtualFrame));
// }
//
// public boolean executeBoolean(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBoolean(this.execute(virtualFrame));
// }
//
// public BigInteger executeBigInteger(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectBigInteger(this.execute(virtualFrame));
// }
//
// public MumblerSymbol executeMumblerSymbol(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerSymbol(this.execute(virtualFrame));
// }
//
// public MumblerFunction executeMumblerFunction(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerFunction(
// this.execute(virtualFrame));
// }
//
// public MumblerList<?> executeMumblerList(VirtualFrame virtualFrame)
// throws UnexpectedResultException {
// return MumblerTypesGen.expectMumblerList(this.execute(virtualFrame));
// }
//
// public String executeString(VirtualFrame virtualFrame)
// throws UnexpectedResultException{
// return MumblerTypesGen.expectString(this.execute(virtualFrame));
// }
//
// protected boolean isArgumentIndexInRange(VirtualFrame virtualFrame,
// int index) {
// return (index + 1) < virtualFrame.getArguments().length;
// }
//
// protected Object getArgument(VirtualFrame virtualFrame, int index) {
// return virtualFrame.getArguments()[index + 1];
// }
//
// protected static MaterializedFrame getLexicalScope(Frame frame) {
// Object[] args = frame.getArguments();
// if (args.length > 0) {
// return (MaterializedFrame) frame.getArguments()[0];
// } else {
// return null;
// }
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/syntax/SymbolSyntax.java
// public class SymbolSyntax extends Syntax<MumblerSymbol> {
// public SymbolSyntax(MumblerSymbol value, SourceSection source) {
// super(value, source);
// }
// }
//
// Path: lang/src/main/java/mumbler/truffle/type/MumblerSymbol.java
// public class MumblerSymbol {
// public final String name;
//
// public MumblerSymbol(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return this.name;
// }
// }
// Path: lang/src/main/java/mumbler/truffle/node/literal/LiteralSymbolNode.java
import mumbler.truffle.node.MumblerNode;
import mumbler.truffle.syntax.SymbolSyntax;
import mumbler.truffle.type.MumblerSymbol;
import com.oracle.truffle.api.frame.VirtualFrame;
package mumbler.truffle.node.literal;
public class LiteralSymbolNode extends MumblerNode {
public final MumblerSymbol symbol;
| public LiteralSymbolNode(SymbolSyntax syntax) { |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileOverviewFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
//
// boolean canceled;
//
// private ProfileOverviewView profileOverviewView;
//
// private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
//
// public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
// this.profileOverviewView = profileOverviewView;
// }
//
// @Override
// public void loadProfileData() {
// canceled = false;
// profileOverviewView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// int donations = parseObjects.size();
// float liters = donations * User.BLOOD_PER_DONATION_LITERS;
// float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
//
// int daysToNext = 73; // TODO
//
// int achievementNum = 0;
//
// if (parseObjects.size() >= 15) {
// achievementNum = 4;
// } else if (parseObjects.size() >= 10) {
// achievementNum = 3;
// } else if (parseObjects.size() >= 5) {
// achievementNum = 2;
// } else if (parseObjects.size() >= 1) {
// achievementNum = 1;
// }
//
// profileOverviewView.hideProgress();
// profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
// String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView; | package hr.foi.rsc.lifeline.fragments;
public class ProfileOverviewFragment extends BaseFragment implements ProfileOverviewView {
@InjectView(R.id.text_donated_liters_value)
TextView textDonatedLitersValue;
@InjectView(R.id.text_current_achievements)
TextView textCurrentAchievements;
@InjectView(R.id.text_ticket)
TextView textTicket;
@InjectView(R.id.text_days_to_next)
TextView textDaysToNext;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
//
// boolean canceled;
//
// private ProfileOverviewView profileOverviewView;
//
// private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
//
// public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
// this.profileOverviewView = profileOverviewView;
// }
//
// @Override
// public void loadProfileData() {
// canceled = false;
// profileOverviewView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// int donations = parseObjects.size();
// float liters = donations * User.BLOOD_PER_DONATION_LITERS;
// float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
//
// int daysToNext = 73; // TODO
//
// int achievementNum = 0;
//
// if (parseObjects.size() >= 15) {
// achievementNum = 4;
// } else if (parseObjects.size() >= 10) {
// achievementNum = 3;
// } else if (parseObjects.size() >= 5) {
// achievementNum = 2;
// } else if (parseObjects.size() >= 1) {
// achievementNum = 1;
// }
//
// profileOverviewView.hideProgress();
// profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
// String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileOverviewFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;
package hr.foi.rsc.lifeline.fragments;
public class ProfileOverviewFragment extends BaseFragment implements ProfileOverviewView {
@InjectView(R.id.text_donated_liters_value)
TextView textDonatedLitersValue;
@InjectView(R.id.text_current_achievements)
TextView textCurrentAchievements;
@InjectView(R.id.text_ticket)
TextView textTicket;
@InjectView(R.id.text_days_to_next)
TextView textDaysToNext;
| private ProfileOverviewPresenter profileOverviewPresenter; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileOverviewFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
//
// boolean canceled;
//
// private ProfileOverviewView profileOverviewView;
//
// private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
//
// public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
// this.profileOverviewView = profileOverviewView;
// }
//
// @Override
// public void loadProfileData() {
// canceled = false;
// profileOverviewView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// int donations = parseObjects.size();
// float liters = donations * User.BLOOD_PER_DONATION_LITERS;
// float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
//
// int daysToNext = 73; // TODO
//
// int achievementNum = 0;
//
// if (parseObjects.size() >= 15) {
// achievementNum = 4;
// } else if (parseObjects.size() >= 10) {
// achievementNum = 3;
// } else if (parseObjects.size() >= 5) {
// achievementNum = 2;
// } else if (parseObjects.size() >= 1) {
// achievementNum = 1;
// }
//
// profileOverviewView.hideProgress();
// profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
// String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView; | package hr.foi.rsc.lifeline.fragments;
public class ProfileOverviewFragment extends BaseFragment implements ProfileOverviewView {
@InjectView(R.id.text_donated_liters_value)
TextView textDonatedLitersValue;
@InjectView(R.id.text_current_achievements)
TextView textCurrentAchievements;
@InjectView(R.id.text_ticket)
TextView textTicket;
@InjectView(R.id.text_days_to_next)
TextView textDaysToNext;
private ProfileOverviewPresenter profileOverviewPresenter;
public ProfileOverviewFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile_overview, container, false);
ButterKnife.inject(this, view);
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
// public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
//
// boolean canceled;
//
// private ProfileOverviewView profileOverviewView;
//
// private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
//
// public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
// this.profileOverviewView = profileOverviewView;
// }
//
// @Override
// public void loadProfileData() {
// canceled = false;
// profileOverviewView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// int donations = parseObjects.size();
// float liters = donations * User.BLOOD_PER_DONATION_LITERS;
// float litersNeededForTicket = liters % User.BLOOD_FOR_TICKET_LITERS;
//
// int daysToNext = 73; // TODO
//
// int achievementNum = 0;
//
// if (parseObjects.size() >= 15) {
// achievementNum = 4;
// } else if (parseObjects.size() >= 10) {
// achievementNum = 3;
// } else if (parseObjects.size() >= 5) {
// achievementNum = 2;
// } else if (parseObjects.size() >= 1) {
// achievementNum = 1;
// }
//
// profileOverviewView.hideProgress();
// profileOverviewView.showData(decimalFormat.format(liters), String.valueOf(daysToNext),
// String.valueOf(achievementNum), decimalFormat.format(litersNeededForTicket));
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileOverviewFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfileOverviewPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;
package hr.foi.rsc.lifeline.fragments;
public class ProfileOverviewFragment extends BaseFragment implements ProfileOverviewView {
@InjectView(R.id.text_donated_liters_value)
TextView textDonatedLitersValue;
@InjectView(R.id.text_current_achievements)
TextView textCurrentAchievements;
@InjectView(R.id.text_ticket)
TextView textTicket;
@InjectView(R.id.text_days_to_next)
TextView textDaysToNext;
private ProfileOverviewPresenter profileOverviewPresenter;
public ProfileOverviewFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile_overview, container, false);
ButterKnife.inject(this, view);
| profileOverviewPresenter = new ProfileOverviewPresenterImpl(this); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
| import android.os.Handler;
import android.os.Looper;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfilePresenterImpl implements ProfilePresenter {
private boolean canceled;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java
import android.os.Handler;
import android.os.Looper;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfilePresenterImpl implements ProfilePresenter {
private boolean canceled;
| private ProfileView profileView; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
| import android.os.Handler;
import android.os.Looper;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfilePresenterImpl implements ProfilePresenter {
private boolean canceled;
private ProfileView profileView;
private Handler mainHandler = new Handler(Looper.getMainLooper());
public ProfilePresenterImpl(ProfileView profileView) {
this.profileView = profileView;
}
@Override
public void saveData(final String name, final String surname, final String address,
final String bloodType, final String sex,
final String additional, final String rhType) {
profileView.showProgress(); | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java
import android.os.Handler;
import android.os.Looper;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.SaveCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfilePresenterImpl implements ProfilePresenter {
private boolean canceled;
private ProfileView profileView;
private Handler mainHandler = new Handler(Looper.getMainLooper());
public ProfilePresenterImpl(ProfileView profileView) {
this.profileView = profileView;
}
@Override
public void saveData(final String name, final String surname, final String address,
final String bloodType, final String sex,
final String additional, final String rhType) {
profileView.showProgress(); | User.getInstance().getUserData(new GetCallback<ParseObject>() { |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java
// public class ProfilePresenterImpl implements ProfilePresenter {
//
// private boolean canceled;
//
// private ProfileView profileView;
//
// private Handler mainHandler = new Handler(Looper.getMainLooper());
//
// public ProfilePresenterImpl(ProfileView profileView) {
// this.profileView = profileView;
// }
//
// @Override
// public void saveData(final String name, final String surname, final String address,
// final String bloodType, final String sex,
// final String additional, final String rhType) {
// profileView.showProgress();
// User.getInstance().getUserData(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// parseObject.put(User.NAME, name);
// parseObject.put(User.SURNAME, surname);
// parseObject.put(User.ADDRESS, address);
// parseObject.put(User.BLOOD_TYPE, bloodType + rhType);
// parseObject.put(User.SEX, sex);
// parseObject.put(User.ADDITIONAL, additional);
// parseObject.saveInBackground();
// profileView.hideProgress();
// }
// });
// }
//
// @Override
// public void saveData(final String address, final String additional) {
// profileView.showProgress();
// User.getInstance().getUserData(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// parseObject.put(User.ADDRESS, address);
// parseObject.put(User.ADDITIONAL, additional);
// parseObject.saveInBackground();
// profileView.hideProgress();
// }
// });
// }
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfilePresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileView; |
@InjectView(R.id.layout_rh)
View layoutRh;
private ProfilePresenter profilePresenter;
private boolean isEdit;
public ProfileFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile, container, false);
ButterKnife.inject(this, view);
if (!ParseUser.getCurrentUser().isNew()) {
isEdit = true;
}
if (isEdit) {
inputName.setVisibility(View.GONE);
inputSurname.setVisibility(View.GONE);
layoutSex.setVisibility(View.GONE);
layoutBloodType.setVisibility(View.GONE);
layoutRh.setVisibility(View.GONE);
showProgress(); | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfilePresenter.java
// public interface ProfilePresenter extends BasePresenter {
//
// public void saveData(String name, String surname, String address, String bloodType, String sex,
// String additional, String rhType);
//
// public void saveData(String address, String additional);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfilePresenterImpl.java
// public class ProfilePresenterImpl implements ProfilePresenter {
//
// private boolean canceled;
//
// private ProfileView profileView;
//
// private Handler mainHandler = new Handler(Looper.getMainLooper());
//
// public ProfilePresenterImpl(ProfileView profileView) {
// this.profileView = profileView;
// }
//
// @Override
// public void saveData(final String name, final String surname, final String address,
// final String bloodType, final String sex,
// final String additional, final String rhType) {
// profileView.showProgress();
// User.getInstance().getUserData(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// parseObject.put(User.NAME, name);
// parseObject.put(User.SURNAME, surname);
// parseObject.put(User.ADDRESS, address);
// parseObject.put(User.BLOOD_TYPE, bloodType + rhType);
// parseObject.put(User.SEX, sex);
// parseObject.put(User.ADDITIONAL, additional);
// parseObject.saveInBackground();
// profileView.hideProgress();
// }
// });
// }
//
// @Override
// public void saveData(final String address, final String additional) {
// profileView.showProgress();
// User.getInstance().getUserData(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// parseObject.put(User.ADDRESS, address);
// parseObject.put(User.ADDITIONAL, additional);
// parseObject.saveInBackground();
// profileView.hideProgress();
// }
// });
// }
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileView.java
// public interface ProfileView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/ProfileFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.parse.GetCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseUser;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfilePresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.ProfilePresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.ProfileView;
@InjectView(R.id.layout_rh)
View layoutRh;
private ProfilePresenter profilePresenter;
private boolean isEdit;
public ProfileFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_profile, container, false);
ButterKnife.inject(this, view);
if (!ParseUser.getCurrentUser().isNew()) {
isEdit = true;
}
if (isEdit) {
inputName.setVisibility(View.GONE);
inputSurname.setVisibility(View.GONE);
layoutSex.setVisibility(View.GONE);
layoutBloodType.setVisibility(View.GONE);
layoutRh.setVisibility(View.GONE);
showProgress(); | User.getInstance().getUserData(new GetCallback<ParseObject>() { |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
| import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class LoginPresenterImpl implements LoginPresenter {
private boolean canceled;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java
import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class LoginPresenterImpl implements LoginPresenter {
private boolean canceled;
| private LoginView loginView; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
| import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView; | ParseTwitterUtils.logIn(activity, logInCallback);
}
@Override
public void resetPassword(String email) {
ParseUser.requestPasswordResetInBackground(email, requestPasswordResetCallback);
}
private RequestPasswordResetCallback requestPasswordResetCallback =
new RequestPasswordResetCallback() {
public void done(ParseException e) {
loginView.hideProgress();
if (e == null) {
loginView.onPasswordReset();
} else {
loginView.showError(e.getMessage());
}
}
};
private LogInCallback logInCallback = new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (canceled) {
return;
}
loginView.hideProgress();
if (parseUser != null) { | // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java
import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView;
ParseTwitterUtils.logIn(activity, logInCallback);
}
@Override
public void resetPassword(String email) {
ParseUser.requestPasswordResetInBackground(email, requestPasswordResetCallback);
}
private RequestPasswordResetCallback requestPasswordResetCallback =
new RequestPasswordResetCallback() {
public void done(ParseException e) {
loginView.hideProgress();
if (e == null) {
loginView.onPasswordReset();
} else {
loginView.showError(e.getMessage());
}
}
};
private LogInCallback logInCallback = new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (canceled) {
return;
}
loginView.hideProgress();
if (parseUser != null) { | if(!parseUser.containsKey(User.TYPE)) { |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
| import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView; |
private RequestPasswordResetCallback requestPasswordResetCallback =
new RequestPasswordResetCallback() {
public void done(ParseException e) {
loginView.hideProgress();
if (e == null) {
loginView.onPasswordReset();
} else {
loginView.showError(e.getMessage());
}
}
};
private LogInCallback logInCallback = new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (canceled) {
return;
}
loginView.hideProgress();
if (parseUser != null) {
if(!parseUser.containsKey(User.TYPE)) {
parseUser.put(User.TYPE, User.DONOR);
parseUser.saveInBackground();
}
if (parseUser.getString(User.TYPE).equals(User.DONOR)) {
loginView.navigateToHome();
} else { | // Path: app/src/main/java/hr/foi/rsc/lifeline/LifeLineApplication.java
// public class LifeLineApplication extends Application {
//
// private static LifeLineApplication instance;
//
// @Override
// public void onCreate() {
// instance = this;
//
// Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
//
// Parse.enableLocalDatastore(getApplicationContext());
// Parse.initialize(this, "Qz1N1B4aBwzmiszChrGKU37QalVXzZ8iew6hV2oH",
// "kWAfX9HmPe1HRXojqj8kuPEufx0r9yXFcoCzVdAq");
// ParseTwitterUtils.initialize("GtQtnF894a6USOPRIVZx2HWfv",
// "yiG7Sn6ZTlVQbKSCtylH9LRmNCGA4Ir6jdNyKXdQMSGu9oQmwx");
// ParseFacebookUtils.initialize("830133423676900");
//
// ParsePush.subscribeInBackground("all", new SaveCallback() {
// @Override
// public void done(ParseException e) {
// if (e == null) {
// Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
// } else {
// Log.e("com.parse.push", "failed to subscribe for push", e);
// }
// }
// });
// }
//
// public static LifeLineApplication getInstance() {
// return instance;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java
import android.app.Activity;
import com.parse.LogInCallback;
import com.parse.ParseException;
import com.parse.ParseFacebookUtils;
import com.parse.ParseTwitterUtils;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;
import hr.foi.rsc.lifeline.LifeLineApplication;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.views.LoginView;
private RequestPasswordResetCallback requestPasswordResetCallback =
new RequestPasswordResetCallback() {
public void done(ParseException e) {
loginView.hideProgress();
if (e == null) {
loginView.onPasswordReset();
} else {
loginView.showError(e.getMessage());
}
}
};
private LogInCallback logInCallback = new LogInCallback() {
@Override
public void done(ParseUser parseUser, ParseException e) {
if (canceled) {
return;
}
loginView.hideProgress();
if (parseUser != null) {
if(!parseUser.containsKey(User.TYPE)) {
parseUser.put(User.TYPE, User.DONOR);
parseUser.saveInBackground();
}
if (parseUser.getString(User.TYPE).equals(User.DONOR)) {
loginView.navigateToHome();
} else { | loginView.showError(LifeLineApplication.getInstance().getString( |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/activities/NavigationDrawerFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/adapters/MenuAdapter.java
// public class MenuAdapter extends ArrayAdapter<MenuItem> {
//
// public MenuAdapter(Context context, int resource,
// MenuItem[] objects) {
// super(context, resource, objects);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// ViewHolder holder;
// if (convertView == null) {
// convertView =
// LayoutInflater.from(getContext()).inflate(R.layout.list_item_menu, parent, false);
// holder = new ViewHolder(convertView);
// } else {
// holder = (ViewHolder) convertView.getTag();
// }
//
// MenuItem item = getItem(position);
//
// holder.itemIcon.setImageResource(item.getIconResId());
// holder.itemTitle.setText(item.getTitleResId());
//
// return convertView;
// }
//
// static class ViewHolder {
//
// @InjectView(R.id.item_icon)
// ImageView itemIcon;
//
// @InjectView(R.id.item_title)
// TextView itemTitle;
//
// ViewHolder(View view) {
// ButterKnife.inject(this, view);
// view.setTag(this);
// }
// }
// }
| import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import butterknife.ButterKnife;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.adapters.MenuAdapter; | package hr.foi.rsc.lifeline.activities;
/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
* design guidelines</a> for a complete explanation of the behaviors implemented here.
*/
public class NavigationDrawerFragment extends Fragment {
/**
* Remember the position of the selected item.
*/
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
/**
* Per the design guidelines, you should show the drawer on launch until the user manually
* expands it. This shared preference tracks this.
*/
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
/**
* A pointer to the current callbacks instance (the Activity).
*/
private NavigationDrawerCallbacks mCallbacks;
/**
* Helper component that ties the action bar to the navigation drawer.
*/
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerListView;
private View mFragmentContainerView;
private int mCurrentSelectedPosition = 0;
private boolean mFromSavedInstanceState;
private boolean mUserLearnedDrawer;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/adapters/MenuAdapter.java
// public class MenuAdapter extends ArrayAdapter<MenuItem> {
//
// public MenuAdapter(Context context, int resource,
// MenuItem[] objects) {
// super(context, resource, objects);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// ViewHolder holder;
// if (convertView == null) {
// convertView =
// LayoutInflater.from(getContext()).inflate(R.layout.list_item_menu, parent, false);
// holder = new ViewHolder(convertView);
// } else {
// holder = (ViewHolder) convertView.getTag();
// }
//
// MenuItem item = getItem(position);
//
// holder.itemIcon.setImageResource(item.getIconResId());
// holder.itemTitle.setText(item.getTitleResId());
//
// return convertView;
// }
//
// static class ViewHolder {
//
// @InjectView(R.id.item_icon)
// ImageView itemIcon;
//
// @InjectView(R.id.item_title)
// TextView itemTitle;
//
// ViewHolder(View view) {
// ButterKnife.inject(this, view);
// view.setTag(this);
// }
// }
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/activities/NavigationDrawerFragment.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import butterknife.ButterKnife;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.adapters.MenuAdapter;
package hr.foi.rsc.lifeline.activities;
/**
* Fragment used for managing interactions for and presentation of a navigation drawer.
* See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction">
* design guidelines</a> for a complete explanation of the behaviors implemented here.
*/
public class NavigationDrawerFragment extends Fragment {
/**
* Remember the position of the selected item.
*/
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
/**
* Per the design guidelines, you should show the drawer on launch until the user manually
* expands it. This shared preference tracks this.
*/
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
/**
* A pointer to the current callbacks instance (the Activity).
*/
private NavigationDrawerCallbacks mCallbacks;
/**
* Helper component that ties the action bar to the navigation drawer.
*/
private ActionBarDrawerToggle mDrawerToggle;
private DrawerLayout mDrawerLayout;
private ListView mDrawerListView;
private View mFragmentContainerView;
private int mCurrentSelectedPosition = 0;
private boolean mFromSavedInstanceState;
private boolean mUserLearnedDrawer;
| private MenuAdapter menuAdapter; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
| import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class AchievementsPresenterImpl implements AchievementsPresenter {
private boolean canceled;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class AchievementsPresenterImpl implements AchievementsPresenter {
private boolean canceled;
| private AchievementsView achievementsView; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
| import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class AchievementsPresenterImpl implements AchievementsPresenter {
private boolean canceled;
private AchievementsView achievementsView;
public AchievementsPresenterImpl(AchievementsView achievementsView) {
this.achievementsView = achievementsView;
}
@Override
public void loadAchievements() {
achievementsView.showProgress(); | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class AchievementsPresenterImpl implements AchievementsPresenter {
private boolean canceled;
private AchievementsView achievementsView;
public AchievementsPresenterImpl(AchievementsView achievementsView) {
this.achievementsView = achievementsView;
}
@Override
public void loadAchievements() {
achievementsView.showProgress(); | User.getInstance().getUserDonations(findCallback); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/fragments/AchievementsFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
// public class AchievementsPresenterImpl implements AchievementsPresenter {
//
// private boolean canceled;
//
// private AchievementsView achievementsView;
//
// public AchievementsPresenterImpl(AchievementsView achievementsView) {
// this.achievementsView = achievementsView;
// }
//
// @Override
// public void loadAchievements() {
// achievementsView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (canceled) {
// return;
// }
//
// achievementsView.hideProgress();
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// boolean[] achievements = new boolean[6];
// achievements[0] = parseObjects.size() >= 1;
// achievements[3] = parseObjects.size() >= 5;
// achievements[4] = parseObjects.size() >= 10;
// achievements[5] = parseObjects.size() >= 15;
//
// achievementsView.showAchievements(achievements);
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.InjectViews;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.AchievementsPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView; | package hr.foi.rsc.lifeline.fragments;
public class AchievementsFragment extends BaseFragment implements AchievementsView {
@InjectView(R.id.achievement_1st_time)
ImageView achievement1stTime;
@InjectView(R.id.achievement_2_year)
ImageView achievement2Year;
@InjectView(R.id.achievement_3_year)
ImageView achievement3Year;
@InjectView(R.id.achievement_5_times)
ImageView achievement5Times;
@InjectView(R.id.achievement_10_times)
ImageView achievement10Times;
@InjectView(R.id.achievement_heart)
ImageView achievementHeart;
@InjectViews({R.id.achievement_1st_time, R.id.achievement_2_year, R.id.achievement_3_year,
R.id.achievement_5_times, R.id.achievement_10_times, R.id.achievement_heart})
List<ImageView> achievementImages;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
// public class AchievementsPresenterImpl implements AchievementsPresenter {
//
// private boolean canceled;
//
// private AchievementsView achievementsView;
//
// public AchievementsPresenterImpl(AchievementsView achievementsView) {
// this.achievementsView = achievementsView;
// }
//
// @Override
// public void loadAchievements() {
// achievementsView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (canceled) {
// return;
// }
//
// achievementsView.hideProgress();
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// boolean[] achievements = new boolean[6];
// achievements[0] = parseObjects.size() >= 1;
// achievements[3] = parseObjects.size() >= 5;
// achievements[4] = parseObjects.size() >= 10;
// achievements[5] = parseObjects.size() >= 15;
//
// achievementsView.showAchievements(achievements);
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/AchievementsFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.InjectViews;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.AchievementsPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView;
package hr.foi.rsc.lifeline.fragments;
public class AchievementsFragment extends BaseFragment implements AchievementsView {
@InjectView(R.id.achievement_1st_time)
ImageView achievement1stTime;
@InjectView(R.id.achievement_2_year)
ImageView achievement2Year;
@InjectView(R.id.achievement_3_year)
ImageView achievement3Year;
@InjectView(R.id.achievement_5_times)
ImageView achievement5Times;
@InjectView(R.id.achievement_10_times)
ImageView achievement10Times;
@InjectView(R.id.achievement_heart)
ImageView achievementHeart;
@InjectViews({R.id.achievement_1st_time, R.id.achievement_2_year, R.id.achievement_3_year,
R.id.achievement_5_times, R.id.achievement_10_times, R.id.achievement_heart})
List<ImageView> achievementImages;
| private AchievementsPresenter achievementsPresenter; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/fragments/AchievementsFragment.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
// public class AchievementsPresenterImpl implements AchievementsPresenter {
//
// private boolean canceled;
//
// private AchievementsView achievementsView;
//
// public AchievementsPresenterImpl(AchievementsView achievementsView) {
// this.achievementsView = achievementsView;
// }
//
// @Override
// public void loadAchievements() {
// achievementsView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (canceled) {
// return;
// }
//
// achievementsView.hideProgress();
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// boolean[] achievements = new boolean[6];
// achievements[0] = parseObjects.size() >= 1;
// achievements[3] = parseObjects.size() >= 5;
// achievements[4] = parseObjects.size() >= 10;
// achievements[5] = parseObjects.size() >= 15;
//
// achievementsView.showAchievements(achievements);
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
| import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.InjectViews;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.AchievementsPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView; | package hr.foi.rsc.lifeline.fragments;
public class AchievementsFragment extends BaseFragment implements AchievementsView {
@InjectView(R.id.achievement_1st_time)
ImageView achievement1stTime;
@InjectView(R.id.achievement_2_year)
ImageView achievement2Year;
@InjectView(R.id.achievement_3_year)
ImageView achievement3Year;
@InjectView(R.id.achievement_5_times)
ImageView achievement5Times;
@InjectView(R.id.achievement_10_times)
ImageView achievement10Times;
@InjectView(R.id.achievement_heart)
ImageView achievementHeart;
@InjectViews({R.id.achievement_1st_time, R.id.achievement_2_year, R.id.achievement_3_year,
R.id.achievement_5_times, R.id.achievement_10_times, R.id.achievement_heart})
List<ImageView> achievementImages;
private AchievementsPresenter achievementsPresenter;
public AchievementsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_achievements, container, false);
ButterKnife.inject(this, view);
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/AchievementsPresenter.java
// public interface AchievementsPresenter extends BasePresenter {
//
// public void loadAchievements();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/AchievementsPresenterImpl.java
// public class AchievementsPresenterImpl implements AchievementsPresenter {
//
// private boolean canceled;
//
// private AchievementsView achievementsView;
//
// public AchievementsPresenterImpl(AchievementsView achievementsView) {
// this.achievementsView = achievementsView;
// }
//
// @Override
// public void loadAchievements() {
// achievementsView.showProgress();
// User.getInstance().getUserDonations(findCallback);
// }
//
// private FindCallback<ParseObject> findCallback = new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> parseObjects, ParseException e) {
//
// if (canceled) {
// return;
// }
//
// achievementsView.hideProgress();
// if (parseObjects == null) {
// parseObjects = new ArrayList<>();
// }
//
// boolean[] achievements = new boolean[6];
// achievements[0] = parseObjects.size() >= 1;
// achievements[3] = parseObjects.size() >= 5;
// achievements[4] = parseObjects.size() >= 10;
// achievements[5] = parseObjects.size() >= 15;
//
// achievementsView.showAchievements(achievements);
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/AchievementsView.java
// public interface AchievementsView extends BaseView {
//
// public void showAchievements(boolean[] achievements);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/fragments/AchievementsFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.util.List;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.InjectViews;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.AchievementsPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.AchievementsPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.AchievementsView;
package hr.foi.rsc.lifeline.fragments;
public class AchievementsFragment extends BaseFragment implements AchievementsView {
@InjectView(R.id.achievement_1st_time)
ImageView achievement1stTime;
@InjectView(R.id.achievement_2_year)
ImageView achievement2Year;
@InjectView(R.id.achievement_3_year)
ImageView achievement3Year;
@InjectView(R.id.achievement_5_times)
ImageView achievement5Times;
@InjectView(R.id.achievement_10_times)
ImageView achievement10Times;
@InjectView(R.id.achievement_heart)
ImageView achievementHeart;
@InjectViews({R.id.achievement_1st_time, R.id.achievement_2_year, R.id.achievement_3_year,
R.id.achievement_5_times, R.id.achievement_10_times, R.id.achievement_heart})
List<ImageView> achievementImages;
private AchievementsPresenter achievementsPresenter;
public AchievementsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_achievements, container, false);
ButterKnife.inject(this, view);
| achievementsPresenter = new AchievementsPresenterImpl(this); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
| import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.views.RegisterView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class RegisterPresenterImpl implements RegisterPresenter {
private boolean canceled;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.views.RegisterView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class RegisterPresenterImpl implements RegisterPresenter {
private boolean canceled;
| private RegisterView registerView; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
| import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.views.RegisterView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class RegisterPresenterImpl implements RegisterPresenter {
private boolean canceled;
private RegisterView registerView;
public RegisterPresenterImpl(RegisterView registerView) {
this.registerView = registerView;
}
@Override
public void register(String username, String password) {
canceled = false;
registerView.showProgress();
ParseUser user = new ParseUser();
user.setUsername(username);
user.setPassword(password);
user.setEmail(username); | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.views.RegisterView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 22/11/14.
*/
public class RegisterPresenterImpl implements RegisterPresenter {
private boolean canceled;
private RegisterView registerView;
public RegisterPresenterImpl(RegisterView registerView) {
this.registerView = registerView;
}
@Override
public void register(String username, String password) {
canceled = false;
registerView.showProgress();
ParseUser user = new ParseUser();
user.setUsername(username);
user.setPassword(password);
user.setEmail(username); | user.put(User.TYPE, User.DONOR); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/activities/LoginActivity.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java
// public class LoginPresenterImpl implements LoginPresenter {
//
// private boolean canceled;
//
// private LoginView loginView;
//
// public LoginPresenterImpl(LoginView loginView) {
// this.loginView = loginView;
// }
//
// @Override
// public void authenticateUser(String username, String password) {
// canceled = false;
// loginView.showProgress();
// ParseUser.logInInBackground(username, password, logInCallback);
// }
//
// @Override
// public void authenticateUserFb(Activity activity) {
// canceled = false;
// ParseFacebookUtils.logIn(activity, logInCallback);
// }
//
// @Override
// public void authenticateUserTwitter(Activity activity) {
// canceled = false;
// ParseTwitterUtils.logIn(activity, logInCallback);
// }
//
// @Override
// public void resetPassword(String email) {
// ParseUser.requestPasswordResetInBackground(email, requestPasswordResetCallback);
// }
//
// private RequestPasswordResetCallback requestPasswordResetCallback =
// new RequestPasswordResetCallback() {
// public void done(ParseException e) {
// loginView.hideProgress();
// if (e == null) {
// loginView.onPasswordReset();
// } else {
// loginView.showError(e.getMessage());
// }
// }
// };
//
// private LogInCallback logInCallback = new LogInCallback() {
// @Override
// public void done(ParseUser parseUser, ParseException e) {
// if (canceled) {
// return;
// }
//
// loginView.hideProgress();
//
// if (parseUser != null) {
// if(!parseUser.containsKey(User.TYPE)) {
// parseUser.put(User.TYPE, User.DONOR);
// parseUser.saveInBackground();
// }
// if (parseUser.getString(User.TYPE).equals(User.DONOR)) {
// loginView.navigateToHome();
// } else {
// loginView.showError(LifeLineApplication.getInstance().getString(
// R.string.only_donors));
// ParseUser.logOut();
// }
// } else {
// if (e != null && e.getMessage() != null) {
// loginView.showError(e.getMessage());
// }
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseUser;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import butterknife.OnLongClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.LoginPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.LoginView; | package hr.foi.rsc.lifeline.activities;
public class LoginActivity extends BaseActivity implements LoginView {
private LoginPresenter loginPresenter;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.inject(this);
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/LoginPresenter.java
// public interface LoginPresenter extends BasePresenter {
//
// public void authenticateUser(String username, String password);
//
// public void authenticateUserFb(Activity activity);
//
// public void authenticateUserTwitter(Activity activity);
//
// public void resetPassword(String email);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/LoginPresenterImpl.java
// public class LoginPresenterImpl implements LoginPresenter {
//
// private boolean canceled;
//
// private LoginView loginView;
//
// public LoginPresenterImpl(LoginView loginView) {
// this.loginView = loginView;
// }
//
// @Override
// public void authenticateUser(String username, String password) {
// canceled = false;
// loginView.showProgress();
// ParseUser.logInInBackground(username, password, logInCallback);
// }
//
// @Override
// public void authenticateUserFb(Activity activity) {
// canceled = false;
// ParseFacebookUtils.logIn(activity, logInCallback);
// }
//
// @Override
// public void authenticateUserTwitter(Activity activity) {
// canceled = false;
// ParseTwitterUtils.logIn(activity, logInCallback);
// }
//
// @Override
// public void resetPassword(String email) {
// ParseUser.requestPasswordResetInBackground(email, requestPasswordResetCallback);
// }
//
// private RequestPasswordResetCallback requestPasswordResetCallback =
// new RequestPasswordResetCallback() {
// public void done(ParseException e) {
// loginView.hideProgress();
// if (e == null) {
// loginView.onPasswordReset();
// } else {
// loginView.showError(e.getMessage());
// }
// }
// };
//
// private LogInCallback logInCallback = new LogInCallback() {
// @Override
// public void done(ParseUser parseUser, ParseException e) {
// if (canceled) {
// return;
// }
//
// loginView.hideProgress();
//
// if (parseUser != null) {
// if(!parseUser.containsKey(User.TYPE)) {
// parseUser.put(User.TYPE, User.DONOR);
// parseUser.saveInBackground();
// }
// if (parseUser.getString(User.TYPE).equals(User.DONOR)) {
// loginView.navigateToHome();
// } else {
// loginView.showError(LifeLineApplication.getInstance().getString(
// R.string.only_donors));
// ParseUser.logOut();
// }
// } else {
// if (e != null && e.getMessage() != null) {
// loginView.showError(e.getMessage());
// }
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/LoginView.java
// public interface LoginView extends BaseView {
//
// public void navigateToHome();
//
// public void onPasswordReset();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/activities/LoginActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.Toast;
import com.parse.ParseUser;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import butterknife.OnLongClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.LoginPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.LoginPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.LoginView;
package hr.foi.rsc.lifeline.activities;
public class LoginActivity extends BaseActivity implements LoginView {
private LoginPresenter loginPresenter;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.inject(this);
| loginPresenter = new LoginPresenterImpl(this); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
| import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
boolean canceled;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
boolean canceled;
| private ProfileOverviewView profileOverviewView; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
| import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView; | package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
boolean canceled;
private ProfileOverviewView profileOverviewView;
private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
this.profileOverviewView = profileOverviewView;
}
@Override
public void loadProfileData() {
canceled = false;
profileOverviewView.showProgress(); | // Path: app/src/main/java/hr/foi/rsc/lifeline/models/User.java
// public class User {
//
// public static final String NAME = "name";
//
// public static final String SURNAME = "surname";
//
// public static final String ADDRESS = "address";
//
// public static final String BLOOD_TYPE = "bloodType";
//
// public static final String SEX = "sex";
//
// public static final String ADDITIONAL = "additional";
//
// public static final String USER_DATA = "UserData";
//
// public static final String USER_OBJECT_ID = "userObjectId";
//
// public static final String USER_DONATION = "UserDonation";
//
// public static final String DONOR = "donor";
//
// public static final String TYPE = "type";
//
// public static final float BLOOD_PER_DONATION_LITERS = 0.5f;
//
// public static final float BLOOD_FOR_TICKET_LITERS = 2f;
//
// private ParseUser parseUser;
//
// public static User getInstance() {
// return new User(ParseUser.getCurrentUser());
// }
//
// public User(ParseUser parseUser) {
// this.parseUser = parseUser;
// }
//
// public void getUserData(final GetCallback<ParseObject> getCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DATA);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.getFirstInBackground(new GetCallback<ParseObject>() {
// @Override
// public void done(ParseObject parseObject, ParseException e) {
// if (parseObject == null) {
// parseObject = new ParseObject(USER_DATA);
// parseObject.put(USER_OBJECT_ID, parseUser.getObjectId());
// getCallback.done(parseObject, e);
// }
// getCallback.done(parseObject, e);
// }
// });
// }
//
// public void getUserDonations(final FindCallback<ParseObject> findCallback) {
// ParseQuery<ParseObject> query = ParseQuery.getQuery(USER_DONATION);
// query.whereEqualTo(USER_OBJECT_ID, parseUser.getObjectId());
// query.findInBackground(new FindCallback<ParseObject>() {
// public void done(List<ParseObject> donationList, ParseException e) {
// findCallback.done(donationList, e);
// }
// });
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/ProfileOverviewPresenter.java
// public interface ProfileOverviewPresenter extends BasePresenter {
//
// public void loadProfileData();
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/ProfileOverviewView.java
// public interface ProfileOverviewView extends BaseView {
//
// public void showData(String liters, String daysToNext, String achievements,
// String litersToFreeTicket);
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/ProfileOverviewPresenterImpl.java
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import hr.foi.rsc.lifeline.models.User;
import hr.foi.rsc.lifeline.mvp.presenters.ProfileOverviewPresenter;
import hr.foi.rsc.lifeline.mvp.views.ProfileOverviewView;
package hr.foi.rsc.lifeline.mvp.presenters.impl;
/**
* Created by dino on 23/11/14.
*/
public class ProfileOverviewPresenterImpl implements ProfileOverviewPresenter {
boolean canceled;
private ProfileOverviewView profileOverviewView;
private static DecimalFormat decimalFormat = new DecimalFormat("0.##");
public ProfileOverviewPresenterImpl(ProfileOverviewView profileOverviewView) {
this.profileOverviewView = profileOverviewView;
}
@Override
public void loadProfileData() {
canceled = false;
profileOverviewView.showProgress(); | User.getInstance().getUserDonations(findCallback); |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/activities/RegisterActivity.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
// public class RegisterPresenterImpl implements RegisterPresenter {
//
// private boolean canceled;
//
// private RegisterView registerView;
//
// public RegisterPresenterImpl(RegisterView registerView) {
// this.registerView = registerView;
// }
//
// @Override
// public void register(String username, String password) {
// canceled = false;
// registerView.showProgress();
//
// ParseUser user = new ParseUser();
// user.setUsername(username);
// user.setPassword(password);
// user.setEmail(username);
// user.put(User.TYPE, User.DONOR);
//
// user.signUpInBackground(signUpCallback);
// }
//
// private SignUpCallback signUpCallback = new SignUpCallback() {
// @Override
// public void done(ParseException e) {
// registerView.hideProgress();
//
// if (canceled) {
// return;
// }
//
// if (e == null) {
// registerView.onSuccess();
// } else {
// registerView.showError(e.getMessage());
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.RegisterPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.RegisterView; | package hr.foi.rsc.lifeline.activities;
public class RegisterActivity extends BaseActivity implements RegisterView {
@InjectView(R.id.my_awesome_toolbar)
protected Toolbar toolbar;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@InjectView(R.id.input_password_confirm)
protected EditText passwordConfirmText;
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
// public class RegisterPresenterImpl implements RegisterPresenter {
//
// private boolean canceled;
//
// private RegisterView registerView;
//
// public RegisterPresenterImpl(RegisterView registerView) {
// this.registerView = registerView;
// }
//
// @Override
// public void register(String username, String password) {
// canceled = false;
// registerView.showProgress();
//
// ParseUser user = new ParseUser();
// user.setUsername(username);
// user.setPassword(password);
// user.setEmail(username);
// user.put(User.TYPE, User.DONOR);
//
// user.signUpInBackground(signUpCallback);
// }
//
// private SignUpCallback signUpCallback = new SignUpCallback() {
// @Override
// public void done(ParseException e) {
// registerView.hideProgress();
//
// if (canceled) {
// return;
// }
//
// if (e == null) {
// registerView.onSuccess();
// } else {
// registerView.showError(e.getMessage());
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/activities/RegisterActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.RegisterPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.RegisterView;
package hr.foi.rsc.lifeline.activities;
public class RegisterActivity extends BaseActivity implements RegisterView {
@InjectView(R.id.my_awesome_toolbar)
protected Toolbar toolbar;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@InjectView(R.id.input_password_confirm)
protected EditText passwordConfirmText;
| private RegisterPresenter registerPresenter; |
reisub/Lifeline-Android | app/src/main/java/hr/foi/rsc/lifeline/activities/RegisterActivity.java | // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
// public class RegisterPresenterImpl implements RegisterPresenter {
//
// private boolean canceled;
//
// private RegisterView registerView;
//
// public RegisterPresenterImpl(RegisterView registerView) {
// this.registerView = registerView;
// }
//
// @Override
// public void register(String username, String password) {
// canceled = false;
// registerView.showProgress();
//
// ParseUser user = new ParseUser();
// user.setUsername(username);
// user.setPassword(password);
// user.setEmail(username);
// user.put(User.TYPE, User.DONOR);
//
// user.signUpInBackground(signUpCallback);
// }
//
// private SignUpCallback signUpCallback = new SignUpCallback() {
// @Override
// public void done(ParseException e) {
// registerView.hideProgress();
//
// if (canceled) {
// return;
// }
//
// if (e == null) {
// registerView.onSuccess();
// } else {
// registerView.showError(e.getMessage());
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
| import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.RegisterPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.RegisterView; | package hr.foi.rsc.lifeline.activities;
public class RegisterActivity extends BaseActivity implements RegisterView {
@InjectView(R.id.my_awesome_toolbar)
protected Toolbar toolbar;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@InjectView(R.id.input_password_confirm)
protected EditText passwordConfirmText;
private RegisterPresenter registerPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.inject(this);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
| // Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/RegisterPresenter.java
// public interface RegisterPresenter extends BasePresenter {
//
// public void register(String username, String password);
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/presenters/impl/RegisterPresenterImpl.java
// public class RegisterPresenterImpl implements RegisterPresenter {
//
// private boolean canceled;
//
// private RegisterView registerView;
//
// public RegisterPresenterImpl(RegisterView registerView) {
// this.registerView = registerView;
// }
//
// @Override
// public void register(String username, String password) {
// canceled = false;
// registerView.showProgress();
//
// ParseUser user = new ParseUser();
// user.setUsername(username);
// user.setPassword(password);
// user.setEmail(username);
// user.put(User.TYPE, User.DONOR);
//
// user.signUpInBackground(signUpCallback);
// }
//
// private SignUpCallback signUpCallback = new SignUpCallback() {
// @Override
// public void done(ParseException e) {
// registerView.hideProgress();
//
// if (canceled) {
// return;
// }
//
// if (e == null) {
// registerView.onSuccess();
// } else {
// registerView.showError(e.getMessage());
// }
// }
// };
//
// @Override
// public void cancel() {
// canceled = true;
// }
// }
//
// Path: app/src/main/java/hr/foi/rsc/lifeline/mvp/views/RegisterView.java
// public interface RegisterView extends BaseView {
//
// public void onSuccess();
// }
// Path: app/src/main/java/hr/foi/rsc/lifeline/activities/RegisterActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.EditText;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import hr.foi.rsc.lifeline.R;
import hr.foi.rsc.lifeline.mvp.presenters.RegisterPresenter;
import hr.foi.rsc.lifeline.mvp.presenters.impl.RegisterPresenterImpl;
import hr.foi.rsc.lifeline.mvp.views.RegisterView;
package hr.foi.rsc.lifeline.activities;
public class RegisterActivity extends BaseActivity implements RegisterView {
@InjectView(R.id.my_awesome_toolbar)
protected Toolbar toolbar;
@InjectView(R.id.input_username)
protected EditText usernameText;
@InjectView(R.id.input_password)
protected EditText passwordText;
@InjectView(R.id.input_password_confirm)
protected EditText passwordConfirmText;
private RegisterPresenter registerPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ButterKnife.inject(this);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
| registerPresenter = new RegisterPresenterImpl(this); |
ogregoire/fror-common | src/main/java/be/fror/common/random/MersenneTwister.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static java.lang.Math.max;
import java.util.Random; | /*
* Copyright 2015 Olivier Grégoire <[email protected]>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.random;
/**
*
* @author Olivier Grégoire <[email protected]>
*/
public final class MersenneTwister extends Random {
private static final int N = 624;
private static final int M = 397;
private static final int UPPER_MASK = 0x80000000;
private static final int LOWER_MASK = 0x7fffffff;
private static final int[] ZERO_OR_MATRIX = {0x0, 0x9908b0df};
private static final int MASK_A = 0x9d2c5680;
private static final int MASK_B = 0xefc60000;
private int[] MT;
private int index;
public MersenneTwister() {
}
public MersenneTwister(long seed) {
setSeed(seed);
}
public MersenneTwister(int[] seed) {
setSeed(seed);
}
@Override
public synchronized void setSeed(long seed) {
MT = new int[N];
MT[0] = (int) seed;
for (int i = 1; i < N; i++) {
MT[i] = (0x6c078965 * (MT[i - 1] ^ (MT[i - 1] >>> 30)) + i);
}
index = N;
}
public synchronized void setSeed(int[] seed) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/be/fror/common/random/MersenneTwister.java
import static be.fror.common.base.Preconditions.checkArgument;
import static java.lang.Math.max;
import java.util.Random;
/*
* Copyright 2015 Olivier Grégoire <[email protected]>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.random;
/**
*
* @author Olivier Grégoire <[email protected]>
*/
public final class MersenneTwister extends Random {
private static final int N = 624;
private static final int M = 397;
private static final int UPPER_MASK = 0x80000000;
private static final int LOWER_MASK = 0x7fffffff;
private static final int[] ZERO_OR_MATRIX = {0x0, 0x9908b0df};
private static final int MASK_A = 0x9d2c5680;
private static final int MASK_B = 0xefc60000;
private int[] MT;
private int index;
public MersenneTwister() {
}
public MersenneTwister(long seed) {
setSeed(seed);
}
public MersenneTwister(int[] seed) {
setSeed(seed);
}
@Override
public synchronized void setSeed(long seed) {
MT = new int[N];
MT[0] = (int) seed;
for (int i = 1; i < N; i++) {
MT[i] = (0x6c078965 * (MT[i - 1] ^ (MT[i - 1] >>> 30)) + i);
}
index = N;
}
public synchronized void setSeed(int[] seed) { | checkArgument(seed.length != 0); |
ogregoire/fror-common | src/main/java/be/fror/common/io/ByteSink.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.nio.charset.Charset; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class ByteSink {
protected ByteSink() {
}
public final OutputStream openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
protected abstract OutputStream doOpenStream() throws IOException;
public CharSink asCharSink(Charset charset) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/ByteSink.java
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.nio.charset.Charset;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class ByteSink {
protected ByteSink() {
}
public final OutputStream openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
protected abstract OutputStream doOpenStream() throws IOException;
public CharSink asCharSink(Charset charset) { | return new AsCharSink(checkNotNull(charset)); |
ogregoire/fror-common | src/main/java/be/fror/common/base/Throwables.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class Throwables {
private Throwables() {
}
public static <X extends Throwable> void propagateIfInstanceOf(
@Nullable Throwable throwable, Class<X> declaredType) throws X {
if (throwable != null && declaredType.isInstance(throwable)) {
throw declaredType.cast(throwable);
}
}
public static void propagateIfPossible(@Nullable Throwable throwable) {
propagateIfInstanceOf(throwable, Error.class);
propagateIfInstanceOf(throwable, RuntimeException.class);
}
public static <X extends Throwable> void propagateIfPossible(
@Nullable Throwable throwable, Class<X> declaredType) throws X {
propagateIfInstanceOf(throwable, declaredType);
propagateIfPossible(throwable);
}
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(
@Nullable Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
throws X1, X2 { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/base/Throwables.java
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class Throwables {
private Throwables() {
}
public static <X extends Throwable> void propagateIfInstanceOf(
@Nullable Throwable throwable, Class<X> declaredType) throws X {
if (throwable != null && declaredType.isInstance(throwable)) {
throw declaredType.cast(throwable);
}
}
public static void propagateIfPossible(@Nullable Throwable throwable) {
propagateIfInstanceOf(throwable, Error.class);
propagateIfInstanceOf(throwable, RuntimeException.class);
}
public static <X extends Throwable> void propagateIfPossible(
@Nullable Throwable throwable, Class<X> declaredType) throws X {
propagateIfInstanceOf(throwable, declaredType);
propagateIfPossible(throwable);
}
public static <X1 extends Throwable, X2 extends Throwable> void propagateIfPossible(
@Nullable Throwable throwable, Class<X1> declaredType1, Class<X2> declaredType2)
throws X1, X2 { | checkNotNull(declaredType2); |
ogregoire/fror-common | src/main/java/be/fror/common/collection/RandomSelector.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import static java.util.Spliterator.IMMUTABLE;
import static java.util.Spliterator.ORDERED;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import java.util.Spliterators;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import javax.annotation.concurrent.ThreadSafe; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.collection;
/**
* A tool to randomly select elements from collections.
*
* <p>
* Example usages:
*
* <pre><code>
* Random random = ...
* Map<String, Double> stringWeights = new Hash<>();
* stringWeights.put("a", 4d);
* stringWeights.put("b", 3d);
* stringWeights.put("c", 12d);
* stringWeights.put("d", 1d);
*
* RandomSelector<String> selector = RandomSelector.weighted(stringWeights.keySet(), s -> stringWeights.get(s));
* List<String> selection = new ArrayList<>();
* for (int i = 0; i < 10; i++) {
* selection.add(selector.next(random));
* }
* </code></pre>
*
*
* @author Olivier Grégoire
* @param <T>
*/
@ThreadSafe
public final class RandomSelector<T> {
/**
* Creates a new random selector based on a uniform distribution.
*
* <p>
* A copy of <tt>elements</tt> is kept, so any modification to <tt>elements</tt> will not be
* reflected in returned values.
*
* @param <T>
* @param elements
* @return
* @throws IllegalArgumentException if <tt>elements</tt> is empty.
*/
public static <T> RandomSelector<T> uniform(final Collection<T> elements)
throws IllegalArgumentException {
requireNonNull(elements, "collection must not be null"); | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/be/fror/common/collection/RandomSelector.java
import static be.fror.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import static java.util.Spliterator.IMMUTABLE;
import static java.util.Spliterator.ORDERED;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import java.util.Spliterators;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import javax.annotation.concurrent.ThreadSafe;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.collection;
/**
* A tool to randomly select elements from collections.
*
* <p>
* Example usages:
*
* <pre><code>
* Random random = ...
* Map<String, Double> stringWeights = new Hash<>();
* stringWeights.put("a", 4d);
* stringWeights.put("b", 3d);
* stringWeights.put("c", 12d);
* stringWeights.put("d", 1d);
*
* RandomSelector<String> selector = RandomSelector.weighted(stringWeights.keySet(), s -> stringWeights.get(s));
* List<String> selection = new ArrayList<>();
* for (int i = 0; i < 10; i++) {
* selection.add(selector.next(random));
* }
* </code></pre>
*
*
* @author Olivier Grégoire
* @param <T>
*/
@ThreadSafe
public final class RandomSelector<T> {
/**
* Creates a new random selector based on a uniform distribution.
*
* <p>
* A copy of <tt>elements</tt> is kept, so any modification to <tt>elements</tt> will not be
* reflected in returned values.
*
* @param <T>
* @param elements
* @return
* @throws IllegalArgumentException if <tt>elements</tt> is empty.
*/
public static <T> RandomSelector<T> uniform(final Collection<T> elements)
throws IllegalArgumentException {
requireNonNull(elements, "collection must not be null"); | checkArgument(!elements.isEmpty(), "collection must not be empty"); |
ogregoire/fror-common | src/main/java/be/fror/common/io/ByteStreams.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; | if (r == -1) {
break;
}
to.write(buf, 0, r);
total += r;
}
return total;
}
static byte[] toByteArray(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
return out.toByteArray();
}
public static byte[] readFully(InputStream in, byte[] bytes) throws IOException {
return readFully(in, bytes, 0, bytes.length);
}
public static byte[] readFully(InputStream in, byte[] bytes, int off, int len) throws IOException {
int read = read(in, bytes, off, len);
if (read != len) {
String message = String.format("reached end of stream after reading %d bytes; %d bytes expected", read, len);
throw new EOFException(message);
}
return bytes;
}
public static int read(InputStream in, byte[] bytes, int off, int len)
throws IOException { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/ByteStreams.java
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
if (r == -1) {
break;
}
to.write(buf, 0, r);
total += r;
}
return total;
}
static byte[] toByteArray(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
return out.toByteArray();
}
public static byte[] readFully(InputStream in, byte[] bytes) throws IOException {
return readFully(in, bytes, 0, bytes.length);
}
public static byte[] readFully(InputStream in, byte[] bytes, int off, int len) throws IOException {
int read = read(in, bytes, off, len);
if (read != len) {
String message = String.format("reached end of stream after reading %d bytes; %d bytes expected", read, len);
throw new EOFException(message);
}
return bytes;
}
public static int read(InputStream in, byte[] bytes, int off, int len)
throws IOException { | checkNotNull(in); |
ogregoire/fror-common | src/main/java/be/fror/common/io/Resources.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Optional; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public final class Resources {
private Resources() {
}
public static ByteSource asByteSource(URL url) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/Resources.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Optional;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public final class Resources {
private Resources() {
}
public static ByteSource asByteSource(URL url) { | return new UrlByteSource(checkNotNull(url)); |
ogregoire/fror-common | src/main/java/be/fror/common/io/Resources.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Optional; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public final class Resources {
private Resources() {
}
public static ByteSource asByteSource(URL url) {
return new UrlByteSource(checkNotNull(url));
}
private static final class UrlByteSource extends ByteSource {
private final URL url;
private UrlByteSource(URL url) {
this.url = url;
}
@Override
public InputStream doOpenStream() throws IOException {
return url.openStream();
}
@Override
public String toString() {
return "Resources.asByteSource(" + url + ")";
}
}
public static CharSource asCharSource(URL url, Charset charset) {
return asByteSource(url)
.asCharSource(charset);
}
public static URL getResource(String resourceName) {
ClassLoader loader = Optional
.ofNullable(Thread.currentThread().getContextClassLoader())
.orElseGet(Resources.class::getClassLoader);
URL url = loader.getResource(resourceName); | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/Resources.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Optional;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public final class Resources {
private Resources() {
}
public static ByteSource asByteSource(URL url) {
return new UrlByteSource(checkNotNull(url));
}
private static final class UrlByteSource extends ByteSource {
private final URL url;
private UrlByteSource(URL url) {
this.url = url;
}
@Override
public InputStream doOpenStream() throws IOException {
return url.openStream();
}
@Override
public String toString() {
return "Resources.asByteSource(" + url + ")";
}
}
public static CharSource asCharSource(URL url, Charset charset) {
return asByteSource(url)
.asCharSource(charset);
}
public static URL getResource(String resourceName) {
ClassLoader loader = Optional
.ofNullable(Thread.currentThread().getContextClassLoader())
.orElseGet(Resources.class::getClassLoader);
URL url = loader.getResource(resourceName); | checkArgument(url != null, "resource %s not found.", resourceName); |
ogregoire/fror-common | src/main/java/be/fror/common/io/CharSource.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.util.stream.Stream; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class CharSource {
protected CharSource() {
}
public final Reader openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public BufferedReader openBufferedStream() throws UncheckedIOException {
Reader reader = openStream();
if (reader instanceof BufferedReader) {
return (BufferedReader) reader;
} else {
return new BufferedReader(reader);
}
}
protected abstract Reader doOpenStream() throws IOException;
public long copyTo(Appendable appendable) throws UncheckedIOException { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/CharSource.java
import static be.fror.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.toList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.io.Writer;
import java.util.stream.Stream;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class CharSource {
protected CharSource() {
}
public final Reader openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public BufferedReader openBufferedStream() throws UncheckedIOException {
Reader reader = openStream();
if (reader instanceof BufferedReader) {
return (BufferedReader) reader;
} else {
return new BufferedReader(reader);
}
}
protected abstract Reader doOpenStream() throws IOException;
public long copyTo(Appendable appendable) throws UncheckedIOException { | checkNotNull(appendable); |
ogregoire/fror-common | src/main/java/be/fror/common/base/Strings.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.text.Normalizer;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
* Tools for String that are not present in Guava.
*
* @author Olivier Grégoire
*/
public final class Strings {
private Strings() {
}
public static String nullToEmpty(@Nullable String string) {
return string == null ? "" : string;
}
@Nullable
public static String emptyToNull(@Nullable String string) {
return isNullOrEmpty(string) ? null : string;
}
public static boolean isNullOrEmpty(@Nullable String string) {
return string == null || string.isEmpty();
}
public static String repeat(String string, int count) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/base/Strings.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.text.Normalizer;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
* Tools for String that are not present in Guava.
*
* @author Olivier Grégoire
*/
public final class Strings {
private Strings() {
}
public static String nullToEmpty(@Nullable String string) {
return string == null ? "" : string;
}
@Nullable
public static String emptyToNull(@Nullable String string) {
return isNullOrEmpty(string) ? null : string;
}
public static boolean isNullOrEmpty(@Nullable String string) {
return string == null || string.isEmpty();
}
public static String repeat(String string, int count) { | checkNotNull(string); |
ogregoire/fror-common | src/main/java/be/fror/common/base/Strings.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.text.Normalizer;
import java.util.regex.Pattern;
import javax.annotation.Nullable; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
* Tools for String that are not present in Guava.
*
* @author Olivier Grégoire
*/
public final class Strings {
private Strings() {
}
public static String nullToEmpty(@Nullable String string) {
return string == null ? "" : string;
}
@Nullable
public static String emptyToNull(@Nullable String string) {
return isNullOrEmpty(string) ? null : string;
}
public static boolean isNullOrEmpty(@Nullable String string) {
return string == null || string.isEmpty();
}
public static String repeat(String string, int count) {
checkNotNull(string);
if (count <= 1) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/base/Strings.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import java.text.Normalizer;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
* Tools for String that are not present in Guava.
*
* @author Olivier Grégoire
*/
public final class Strings {
private Strings() {
}
public static String nullToEmpty(@Nullable String string) {
return string == null ? "" : string;
}
@Nullable
public static String emptyToNull(@Nullable String string) {
return isNullOrEmpty(string) ? null : string;
}
public static boolean isNullOrEmpty(@Nullable String string) {
return string == null || string.isEmpty();
}
public static String repeat(String string, int count) {
checkNotNull(string);
if (count <= 1) { | checkArgument(count >= 0, "Invalid count: %s", count); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
*
* @author Olivier Grégoire
*/
@ThreadSafe
public final class ResourceLocator {
// Notes:
// * http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html
private static final Set<String> supportedProtocols = Collections.unmodifiableSet(new LinkedHashSet<>(asList("file", "jar")));
private final ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources;
private ResourceLocator(ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources) {
this.resources = resources;
}
/**
* Locates resources matching the glob-pattern {@code namePattern}. Resources are
* "folder-separated" with {@code /}.
*
* <p>
* Pattern definition:
* <ul>
* <li>Follow the rules of {@link FileSystem#getPathMatcher(java.lang.String) }</li>
* <li>remove the "glob:" prefix</li>
* <li>regex is not supported</li>
* <li>brackets expressions are not supported</li>
* </ul>
*
* <p>
* <b>Note:</b> the resource names don't start with {@code /}.
*
* <p>
* Example of usage:
*
* <pre>{@code
* locateResources("**/*.properties") // Finds any resource whose name ends with ".properties".
* locateResources("**/*.{java,class}") // Finds any resource whose name ends with ".java" or ".class".
* locateResources("**/*.???") // Finds any resource whose name ends with a dot then three characters.
* }</pre>
*
* @param namePattern
* @return
*/
public Stream<URL> locateResources(String namePattern) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
*
* @author Olivier Grégoire
*/
@ThreadSafe
public final class ResourceLocator {
// Notes:
// * http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html
private static final Set<String> supportedProtocols = Collections.unmodifiableSet(new LinkedHashSet<>(asList("file", "jar")));
private final ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources;
private ResourceLocator(ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources) {
this.resources = resources;
}
/**
* Locates resources matching the glob-pattern {@code namePattern}. Resources are
* "folder-separated" with {@code /}.
*
* <p>
* Pattern definition:
* <ul>
* <li>Follow the rules of {@link FileSystem#getPathMatcher(java.lang.String) }</li>
* <li>remove the "glob:" prefix</li>
* <li>regex is not supported</li>
* <li>brackets expressions are not supported</li>
* </ul>
*
* <p>
* <b>Note:</b> the resource names don't start with {@code /}.
*
* <p>
* Example of usage:
*
* <pre>{@code
* locateResources("**/*.properties") // Finds any resource whose name ends with ".properties".
* locateResources("**/*.{java,class}") // Finds any resource whose name ends with ".java" or ".class".
* locateResources("**/*.???") // Finds any resource whose name ends with a dot then three characters.
* }</pre>
*
* @param namePattern
* @return
*/
public Stream<URL> locateResources(String namePattern) { | checkNotNull(namePattern); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
*
* @author Olivier Grégoire
*/
@ThreadSafe
public final class ResourceLocator {
// Notes:
// * http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html
private static final Set<String> supportedProtocols = Collections.unmodifiableSet(new LinkedHashSet<>(asList("file", "jar")));
private final ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources;
private ResourceLocator(ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources) {
this.resources = resources;
}
/**
* Locates resources matching the glob-pattern {@code namePattern}. Resources are
* "folder-separated" with {@code /}.
*
* <p>
* Pattern definition:
* <ul>
* <li>Follow the rules of {@link FileSystem#getPathMatcher(java.lang.String) }</li>
* <li>remove the "glob:" prefix</li>
* <li>regex is not supported</li>
* <li>brackets expressions are not supported</li>
* </ul>
*
* <p>
* <b>Note:</b> the resource names don't start with {@code /}.
*
* <p>
* Example of usage:
*
* <pre>{@code
* locateResources("**/*.properties") // Finds any resource whose name ends with ".properties".
* locateResources("**/*.{java,class}") // Finds any resource whose name ends with ".java" or ".class".
* locateResources("**/*.???") // Finds any resource whose name ends with a dot then three characters.
* }</pre>
*
* @param namePattern
* @return
*/
public Stream<URL> locateResources(String namePattern) {
checkNotNull(namePattern);
Pattern p = Pattern.compile(globToRegex(namePattern));
return doLocateResources((name) -> p.matcher(name).matches());
}
public Stream<URL> locateResources(Predicate<String> namePredicate) {
checkNotNull(namePredicate);
return doLocateResources(namePredicate);
}
/**
* Returns a stream of resources which names match {@code namePattern} and that are transformed
* into {@code T}s using {@code loader}.
*
* <p>
* Using a terminal operation on the stream may throw an {@link UncheckedIOException} wrapping an
* {@link IOException} thrown by {@code loader}.
*
* @param <T>
* @param namePattern
* @param loader
* @return
*/
public <T> Stream<T> loadResources(String namePattern, ResourceLoader<T> loader) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
*
* @author Olivier Grégoire
*/
@ThreadSafe
public final class ResourceLocator {
// Notes:
// * http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html
private static final Set<String> supportedProtocols = Collections.unmodifiableSet(new LinkedHashSet<>(asList("file", "jar")));
private final ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources;
private ResourceLocator(ImmutableMultimap<ClassLoader, ClassPath.ResourceInfo> resources) {
this.resources = resources;
}
/**
* Locates resources matching the glob-pattern {@code namePattern}. Resources are
* "folder-separated" with {@code /}.
*
* <p>
* Pattern definition:
* <ul>
* <li>Follow the rules of {@link FileSystem#getPathMatcher(java.lang.String) }</li>
* <li>remove the "glob:" prefix</li>
* <li>regex is not supported</li>
* <li>brackets expressions are not supported</li>
* </ul>
*
* <p>
* <b>Note:</b> the resource names don't start with {@code /}.
*
* <p>
* Example of usage:
*
* <pre>{@code
* locateResources("**/*.properties") // Finds any resource whose name ends with ".properties".
* locateResources("**/*.{java,class}") // Finds any resource whose name ends with ".java" or ".class".
* locateResources("**/*.???") // Finds any resource whose name ends with a dot then three characters.
* }</pre>
*
* @param namePattern
* @return
*/
public Stream<URL> locateResources(String namePattern) {
checkNotNull(namePattern);
Pattern p = Pattern.compile(globToRegex(namePattern));
return doLocateResources((name) -> p.matcher(name).matches());
}
public Stream<URL> locateResources(Predicate<String> namePredicate) {
checkNotNull(namePredicate);
return doLocateResources(namePredicate);
}
/**
* Returns a stream of resources which names match {@code namePattern} and that are transformed
* into {@code T}s using {@code loader}.
*
* <p>
* Using a terminal operation on the stream may throw an {@link UncheckedIOException} wrapping an
* {@link IOException} thrown by {@code loader}.
*
* @param <T>
* @param namePattern
* @param loader
* @return
*/
public <T> Stream<T> loadResources(String namePattern, ResourceLoader<T> loader) { | return locateResources(namePattern).map(url -> loader.uncheckedLoad(asByteSource(url))); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | return locateResources(namePredicate).map(url -> new Resource<>(asByteSource(url), loader));
}
private Stream<URL> doLocateResources(Predicate<String> namePredicate) {
return resources.values().stream()
.filter(r -> namePredicate.test(r.getResourceName()))
.map(ClassPath.ResourceInfo::url);
}
private static final String SERVICE_PREFIX = "META-INF/services/";
public <T> Stream<Class<? extends T>> getServices(Class<T> service) {
return getImplementationNames(service.getName()).entrySet().stream()
.flatMap(e -> toClasses(e, service));
}
private Map<ClassLoader, List<String>> getImplementationNames(String serviceName) {
final String resourceName = SERVICE_PREFIX + serviceName;
Map<ClassLoader, List<String>> implementationNames = new LinkedHashMap<>();
resources.asMap().keySet().stream().forEach((classLoader) -> {
URL url = classLoader.getResource(resourceName);
if (url != null) {
implementationNames.computeIfAbsent(classLoader, (cl) -> new ArrayList<>()).addAll(urlToServiceNames(url));
}
});
return implementationNames;
}
private static List<String> urlToServiceNames(URL url) {
// ServiceLoader's doc says that the service provider file is UTF-8-encoded. | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
return locateResources(namePredicate).map(url -> new Resource<>(asByteSource(url), loader));
}
private Stream<URL> doLocateResources(Predicate<String> namePredicate) {
return resources.values().stream()
.filter(r -> namePredicate.test(r.getResourceName()))
.map(ClassPath.ResourceInfo::url);
}
private static final String SERVICE_PREFIX = "META-INF/services/";
public <T> Stream<Class<? extends T>> getServices(Class<T> service) {
return getImplementationNames(service.getName()).entrySet().stream()
.flatMap(e -> toClasses(e, service));
}
private Map<ClassLoader, List<String>> getImplementationNames(String serviceName) {
final String resourceName = SERVICE_PREFIX + serviceName;
Map<ClassLoader, List<String>> implementationNames = new LinkedHashMap<>();
resources.asMap().keySet().stream().forEach((classLoader) -> {
URL url = classLoader.getResource(resourceName);
if (url != null) {
implementationNames.computeIfAbsent(classLoader, (cl) -> new ArrayList<>()).addAll(urlToServiceNames(url));
}
});
return implementationNames;
}
private static List<String> urlToServiceNames(URL url) {
// ServiceLoader's doc says that the service provider file is UTF-8-encoded. | return asCharSource(url, UTF_8).readLines() |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | implementationNames.computeIfAbsent(classLoader, (cl) -> new ArrayList<>()).addAll(urlToServiceNames(url));
}
});
return implementationNames;
}
private static List<String> urlToServiceNames(URL url) {
// ServiceLoader's doc says that the service provider file is UTF-8-encoded.
return asCharSource(url, UTF_8).readLines()
.map(ResourceLocator::removeCommentAndTrim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}
private static String removeCommentAndTrim(String line) {
int sharpPos = line.indexOf('#');
if (sharpPos >= 0) {
line = line.substring(0, sharpPos);
}
return line.trim();
}
private static <T> Stream<Class<? extends T>> toClasses(Map.Entry<ClassLoader, List<String>> entry, Class<T> service) {
return entry.getValue().stream().map(value -> toClass(value, service, entry.getKey()));
}
private static <T> Class<? extends T> toClass(String name, Class<T> service, ClassLoader loader) {
try {
return (Class<? extends T>) Class.forName(name, false, loader);
} catch (ClassNotFoundException e) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
implementationNames.computeIfAbsent(classLoader, (cl) -> new ArrayList<>()).addAll(urlToServiceNames(url));
}
});
return implementationNames;
}
private static List<String> urlToServiceNames(URL url) {
// ServiceLoader's doc says that the service provider file is UTF-8-encoded.
return asCharSource(url, UTF_8).readLines()
.map(ResourceLocator::removeCommentAndTrim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toList());
}
private static String removeCommentAndTrim(String line) {
int sharpPos = line.indexOf('#');
if (sharpPos >= 0) {
line = line.substring(0, sharpPos);
}
return line.trim();
}
private static <T> Stream<Class<? extends T>> toClasses(Map.Entry<ClassLoader, List<String>> entry, Class<T> service) {
return entry.getValue().stream().map(value -> toClass(value, service, entry.getKey()));
}
private static <T> Class<? extends T> toClass(String name, Class<T> service, ClassLoader loader) {
try {
return (Class<? extends T>) Class.forName(name, false, loader);
} catch (ClassNotFoundException e) { | throw propagate(e); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | * @param classLoader
* @return
* @throws IllegalArgumentException
*/
public Builder addClassLoader(URLClassLoader classLoader) {
checkNotNull(classLoader, "classLoader must not be null");
stream(classLoader.getURLs())
.filter((url) -> supportedProtocols.contains(url.getProtocol()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("No URL in URLClassLoader are usable"));
classLoaders.add(classLoader);
return this;
}
/**
*
* @param jarSource
* @return throws IllegalArgumentException
*/
public Builder addJar(Path jarSource) {
checkNotNull(jarSource);
try {
new JarFile(jarSource.toFile()); // Check that it's a valid jar file.
URL url = jarSource.toUri().toURL();
try {
url = new URL("jar", "", -1, url.toString() + "!/");
} catch (MalformedURLException unused) {
}
classLoaders.add(new URLClassLoader(new URL[]{url}, null));
} catch (IOException unused) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
* @param classLoader
* @return
* @throws IllegalArgumentException
*/
public Builder addClassLoader(URLClassLoader classLoader) {
checkNotNull(classLoader, "classLoader must not be null");
stream(classLoader.getURLs())
.filter((url) -> supportedProtocols.contains(url.getProtocol()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("No URL in URLClassLoader are usable"));
classLoaders.add(classLoader);
return this;
}
/**
*
* @param jarSource
* @return throws IllegalArgumentException
*/
public Builder addJar(Path jarSource) {
checkNotNull(jarSource);
try {
new JarFile(jarSource.toFile()); // Check that it's a valid jar file.
URL url = jarSource.toUri().toURL();
try {
url = new URL("jar", "", -1, url.toString() + "!/");
} catch (MalformedURLException unused) {
}
classLoaders.add(new URLClassLoader(new URL[]{url}, null));
} catch (IOException unused) { | checkArgument(false, "jarSource doesn't refer to a valid jar file"); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLocator.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe; | classLoaders.add(new URLClassLoader(new URL[]{url}, null));
} catch (IOException unused) {
checkArgument(false, "jarSource doesn't refer to a valid jar file");
}
return this;
}
/**
*
* @param directorySource
* @return
* @throws IllegalArgumentException
*/
public Builder addDirectory(Path directorySource) {
checkNotNull(directorySource);
checkArgument(isDirectory(directorySource), "directorySource is not a directory");
try {
classLoaders.add(new URLClassLoader(new URL[]{directorySource.toUri().toURL()}, null));
} catch (IOException unused) {
checkArgument(false, "directorySource cannot be mapped to a URL");
}
return this;
}
/**
*
* @return @throws IOException
* @throws IllegalStateException
*/
public ResourceLocator build() throws IOException { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkState(boolean expression) {
// if (!expression) {
// throw new IllegalStateException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Throwables.java
// public static RuntimeException propagate(Throwable throwable) {
// propagateIfPossible(checkNotNull(throwable));
// throw new RuntimeException(throwable);
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static ByteSource asByteSource(URL url) {
// return new UrlByteSource(checkNotNull(url));
// }
//
// Path: src/main/java/be/fror/common/io/Resources.java
// public static CharSource asCharSource(URL url, Charset charset) {
// return asByteSource(url)
// .asCharSource(charset);
// }
// Path: src/main/java/be/fror/common/resource/ResourceLocator.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkState;
import static be.fror.common.base.Throwables.propagate;
import static be.fror.common.io.Resources.asByteSource;
import static be.fror.common.io.Resources.asCharSource;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.isDirectory;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
import com.google.common.base.CharMatcher;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.function.Predicate;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.concurrent.ThreadSafe;
classLoaders.add(new URLClassLoader(new URL[]{url}, null));
} catch (IOException unused) {
checkArgument(false, "jarSource doesn't refer to a valid jar file");
}
return this;
}
/**
*
* @param directorySource
* @return
* @throws IllegalArgumentException
*/
public Builder addDirectory(Path directorySource) {
checkNotNull(directorySource);
checkArgument(isDirectory(directorySource), "directorySource is not a directory");
try {
classLoaders.add(new URLClassLoader(new URL[]{directorySource.toUri().toURL()}, null));
} catch (IOException unused) {
checkArgument(false, "directorySource cannot be mapped to a URL");
}
return this;
}
/**
*
* @return @throws IOException
* @throws IllegalStateException
*/
public ResourceLocator build() throws IOException { | checkState(!classLoaders.isEmpty(), "At least one source must be added"); |
ogregoire/fror-common | src/main/java/be/fror/common/io/ByteSource.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.nio.charset.Charset; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class ByteSource {
protected ByteSource() {
}
public final InputStream openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
protected abstract InputStream doOpenStream() throws IOException;
public CharSource asCharSource(Charset charset) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/io/ByteSource.java
import static be.fror.common.base.Preconditions.checkNotNull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
public abstract class ByteSource {
protected ByteSource() {
}
public final InputStream openStream() throws UncheckedIOException {
try {
return doOpenStream();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
protected abstract InputStream doOpenStream() throws IOException;
public CharSource asCharSource(Charset charset) { | return new AsCharSource(checkNotNull(charset)); |
ogregoire/fror-common | src/test/java/be/fror/common/resource/ResourceLocatorTest.java | // Path: src/main/java/be/fror/common/resource/ResourceLoaders.java
// public static ResourceLoader<Properties> propertiesLoader() {
// return InputStreamPropertiesLoader.PROPERTIES;
// }
| import static be.fror.common.resource.ResourceLoaders.propertiesLoader;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger; | public void setUp() throws IOException {
instance = new ResourceLocator.Builder()
.addClassLoader((URLClassLoader) ResourceLocatorTest.class.getClassLoader())
.build();
}
@After
public void tearDown() {
}
/**
* Test of locateResources method, of class ResourceLocator.
*/
@Test
public void testLocateResources_String() {
List<URL> urls = instance.locateResources("books/*.properties").collect(toList());
assertThat(urls.size(), is(2));
}
/**
* Test of locateResources method, of class ResourceLocator.
*/
@Test
public void testLocateResources_Predicate() {
}
@Test
public void testGetResources_String() {
Properties agot = instance | // Path: src/main/java/be/fror/common/resource/ResourceLoaders.java
// public static ResourceLoader<Properties> propertiesLoader() {
// return InputStreamPropertiesLoader.PROPERTIES;
// }
// Path: src/test/java/be/fror/common/resource/ResourceLocatorTest.java
import static be.fror.common.resource.ResourceLoaders.propertiesLoader;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
public void setUp() throws IOException {
instance = new ResourceLocator.Builder()
.addClassLoader((URLClassLoader) ResourceLocatorTest.class.getClassLoader())
.build();
}
@After
public void tearDown() {
}
/**
* Test of locateResources method, of class ResourceLocator.
*/
@Test
public void testLocateResources_String() {
List<URL> urls = instance.locateResources("books/*.properties").collect(toList());
assertThat(urls.size(), is(2));
}
/**
* Test of locateResources method, of class ResourceLocator.
*/
@Test
public void testLocateResources_Predicate() {
}
@Test
public void testGetResources_String() {
Properties agot = instance | .loadResources("books/a_game_of_thrones.properties", propertiesLoader(UTF_8)) |
ogregoire/fror-common | src/main/java/be/fror/common/io/CharSequenceReader.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
final class CharSequenceReader extends Reader {
private CharSequence seq;
private int pos;
private int mark;
CharSequenceReader(CharSequence seq) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
// Path: src/main/java/be/fror/common/io/CharSequenceReader.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.io;
/**
*
* @author Olivier Grégoire
*/
final class CharSequenceReader extends Reader {
private CharSequence seq;
private int pos;
private int mark;
CharSequenceReader(CharSequence seq) { | this.seq = checkNotNull(seq); |
ogregoire/fror-common | src/main/java/be/fror/common/io/CharSequenceReader.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer; | private boolean hasRemaining() {
return remaining() > 0;
}
private int remaining() {
return seq.length() - pos;
}
@Override
public synchronized int read(CharBuffer target) throws IOException {
checkNotNull(target);
checkOpen();
if (!hasRemaining()) {
return -1;
}
int charsToRead = Math.min(target.remaining(), remaining());
for (int i = 0; i < charsToRead; i++) {
target.put(seq.charAt(pos++));
}
return charsToRead;
}
@Override
public synchronized int read() throws IOException {
checkOpen();
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@Override
public synchronized int read(char[] cbuf, int off, int len) throws IOException { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
// Path: src/main/java/be/fror/common/io/CharSequenceReader.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
private boolean hasRemaining() {
return remaining() > 0;
}
private int remaining() {
return seq.length() - pos;
}
@Override
public synchronized int read(CharBuffer target) throws IOException {
checkNotNull(target);
checkOpen();
if (!hasRemaining()) {
return -1;
}
int charsToRead = Math.min(target.remaining(), remaining());
for (int i = 0; i < charsToRead; i++) {
target.put(seq.charAt(pos++));
}
return charsToRead;
}
@Override
public synchronized int read() throws IOException {
checkOpen();
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@Override
public synchronized int read(char[] cbuf, int off, int len) throws IOException { | checkPositionIndexes(off, off + len, cbuf.length); |
ogregoire/fror-common | src/main/java/be/fror/common/io/CharSequenceReader.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer; | }
int charsToRead = Math.min(target.remaining(), remaining());
for (int i = 0; i < charsToRead; i++) {
target.put(seq.charAt(pos++));
}
return charsToRead;
}
@Override
public synchronized int read() throws IOException {
checkOpen();
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@Override
public synchronized int read(char[] cbuf, int off, int len) throws IOException {
checkPositionIndexes(off, off + len, cbuf.length);
checkOpen();
if (!hasRemaining()) {
return -1;
}
int charsToRead = Math.min(len, remaining());
for (int i = 0; i < charsToRead; i++) {
cbuf[off + i] = seq.charAt(pos++);
}
return charsToRead;
}
@Override
public synchronized long skip(long n) throws IOException { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static void checkPositionIndexes(int start, int end, int size) {
// if (start < 0 || end < start || end > size) {
// throw new IndexOutOfBoundsException(badPositionIndexes(start, end, size));
// }
// }
// Path: src/main/java/be/fror/common/io/CharSequenceReader.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static be.fror.common.base.Preconditions.checkPositionIndexes;
import java.io.IOException;
import java.io.Reader;
import java.nio.CharBuffer;
}
int charsToRead = Math.min(target.remaining(), remaining());
for (int i = 0; i < charsToRead; i++) {
target.put(seq.charAt(pos++));
}
return charsToRead;
}
@Override
public synchronized int read() throws IOException {
checkOpen();
return hasRemaining() ? seq.charAt(pos++) : -1;
}
@Override
public synchronized int read(char[] cbuf, int off, int len) throws IOException {
checkPositionIndexes(off, off + len, cbuf.length);
checkOpen();
if (!hasRemaining()) {
return -1;
}
int charsToRead = Math.min(len, remaining());
for (int i = 0; i < charsToRead; i++) {
cbuf[off + i] = seq.charAt(pos++);
}
return charsToRead;
}
@Override
public synchronized long skip(long n) throws IOException { | checkArgument(n >= 0, "n (%s) may not be negative", n); |
ogregoire/fror-common | src/main/java/be/fror/common/primitives/Ints.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.primitives;
/**
*
* @author Olivier Grégoire
*/
public final class Ints {
private Ints() {
}
public static int fromBigEndianByteArray(byte[] bytes) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/be/fror/common/primitives/Ints.java
import static be.fror.common.base.Preconditions.checkArgument;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.primitives;
/**
*
* @author Olivier Grégoire
*/
public final class Ints {
private Ints() {
}
public static int fromBigEndianByteArray(byte[] bytes) { | checkArgument(bytes.length >= Integer.BYTES, "array too small: %s < %s", bytes.length, Integer.BYTES); |
ogregoire/fror-common | src/main/java/be/fror/common/collection/SparseArray.java | // Path: src/main/java/be/fror/common/base/MoreArrays.java
// public final class MoreArrays {
//
// private MoreArrays() {
// }
//
// public static <T> T[] append(T[] array, int currentSize, T element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// T[] copy = newArray(array, growSize(currentSize));
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static int[] append(int[] array, int currentSize, int element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// int[] copy = new int[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static long[] append(long[] array, int currentSize, long element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// long[] copy = new long[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static boolean[] append(boolean[] array, int currentSize, boolean element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// boolean[] copy = new boolean[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static <T> T[] insert(T[] array, int currentSize, int index, T element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// T[] newArray = newArray(array, growSize(currentSize));
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static int[] insert(int[] array, int currentSize, int index, int element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// int[] newArray = new int[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static long[] insert(long[] array, int currentSize, int index, long element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// long[] newArray = new long[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static boolean[] insert(boolean[] array, int currentSize, int index, boolean element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// boolean[] newArray = new boolean[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// private static <T> T[] newArray(T[] array, int newSize) {
// return (T[]) Array.newInstance(array.getClass().getComponentType(), newSize);
// }
//
// private static int growSize(int currentSize) {
// return currentSize <= 8 ? 16 : Integer.highestOneBit(currentSize) << 1;
// }
// }
| import be.fror.common.base.MoreArrays;
import java.util.Arrays; | } else {
return (E) values[i];
}
}
public void remove(int key) {
int i = Arrays.binarySearch(keys, 0, size, key);
if (i >= 0) {
if (values[i] != DELETED) {
values[i] = DELETED;
dirty = true;
}
}
}
public void put(int key, E value) {
int i = Arrays.binarySearch(keys, 0, size, key);
if (i >= 0) {
values[i] = value;
} else {
i = ~i;
if (i < size && values[i] == DELETED) {
keys[i] = key;
values[i] = value;
return;
}
if (dirty && size >= keys.length) {
cleanup();
i = ~Arrays.binarySearch(keys, 0, size, key);
} | // Path: src/main/java/be/fror/common/base/MoreArrays.java
// public final class MoreArrays {
//
// private MoreArrays() {
// }
//
// public static <T> T[] append(T[] array, int currentSize, T element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// T[] copy = newArray(array, growSize(currentSize));
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static int[] append(int[] array, int currentSize, int element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// int[] copy = new int[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static long[] append(long[] array, int currentSize, long element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// long[] copy = new long[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static boolean[] append(boolean[] array, int currentSize, boolean element) {
// checkArgument(currentSize <= array.length);
// if (currentSize == array.length) {
// boolean[] copy = new boolean[growSize(currentSize)];
// System.arraycopy(array, 0, copy, 0, currentSize);
// array = copy;
// }
// array[currentSize] = element;
// return array;
// }
//
// public static <T> T[] insert(T[] array, int currentSize, int index, T element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// T[] newArray = newArray(array, growSize(currentSize));
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static int[] insert(int[] array, int currentSize, int index, int element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// int[] newArray = new int[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static long[] insert(long[] array, int currentSize, int index, long element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// long[] newArray = new long[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// public static boolean[] insert(boolean[] array, int currentSize, int index, boolean element) {
// checkArgument(currentSize <= array.length);
// if (currentSize < array.length) {
// System.arraycopy(array, index, array, index + 1, currentSize - index);
// array[index] = element;
// return array;
// }
// boolean[] newArray = new boolean[growSize(currentSize)];
// System.arraycopy(array, 0, newArray, 0, index);
// System.arraycopy(array, index, newArray, index + 1, array.length - index);
// newArray[index] = element;
// return newArray;
// }
//
// private static <T> T[] newArray(T[] array, int newSize) {
// return (T[]) Array.newInstance(array.getClass().getComponentType(), newSize);
// }
//
// private static int growSize(int currentSize) {
// return currentSize <= 8 ? 16 : Integer.highestOneBit(currentSize) << 1;
// }
// }
// Path: src/main/java/be/fror/common/collection/SparseArray.java
import be.fror.common.base.MoreArrays;
import java.util.Arrays;
} else {
return (E) values[i];
}
}
public void remove(int key) {
int i = Arrays.binarySearch(keys, 0, size, key);
if (i >= 0) {
if (values[i] != DELETED) {
values[i] = DELETED;
dirty = true;
}
}
}
public void put(int key, E value) {
int i = Arrays.binarySearch(keys, 0, size, key);
if (i >= 0) {
values[i] = value;
} else {
i = ~i;
if (i < size && values[i] == DELETED) {
keys[i] = key;
values[i] = value;
return;
}
if (dirty && size >= keys.length) {
cleanup();
i = ~Arrays.binarySearch(keys, 0, size, key);
} | keys = MoreArrays.insert(keys, size, i, key); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLoaders.java | // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
| import java.util.Map;
import java.util.Properties;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_16;
import static java.nio.charset.StandardCharsets.UTF_16BE;
import static java.nio.charset.StandardCharsets.UTF_16LE;
import static java.nio.charset.StandardCharsets.UTF_8;
import be.fror.common.io.ByteSource;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Tools for {@link ResourceLoader}, including static factory methods.
*
* @author Olivier Grégoire
*/
public final class ResourceLoaders {
private ResourceLoaders() {
}
/**
* Returns a {code ResourceLoader} able to load {@link Properties} using
* {@link Properties#load(java.io.InputStream)}
*
* @return
*/
public static ResourceLoader<Properties> propertiesLoader() {
return InputStreamPropertiesLoader.PROPERTIES;
}
/**
* Returns a {code ResourceLoader} able to load {@link Properties} using
* {@link Properties#loadFromXML(java.io.InputStream)}
*
* @return
*/
public static ResourceLoader<Properties> xmlPropertiesLoader() {
return InputStreamPropertiesLoader.XML;
}
private static interface PropertiesLoader extends ResourceLoader<Properties> {
@Override | // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
// Path: src/main/java/be/fror/common/resource/ResourceLoaders.java
import java.util.Map;
import java.util.Properties;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static java.nio.charset.StandardCharsets.UTF_16;
import static java.nio.charset.StandardCharsets.UTF_16BE;
import static java.nio.charset.StandardCharsets.UTF_16LE;
import static java.nio.charset.StandardCharsets.UTF_8;
import be.fror.common.io.ByteSource;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.HashMap;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Tools for {@link ResourceLoader}, including static factory methods.
*
* @author Olivier Grégoire
*/
public final class ResourceLoaders {
private ResourceLoaders() {
}
/**
* Returns a {code ResourceLoader} able to load {@link Properties} using
* {@link Properties#load(java.io.InputStream)}
*
* @return
*/
public static ResourceLoader<Properties> propertiesLoader() {
return InputStreamPropertiesLoader.PROPERTIES;
}
/**
* Returns a {code ResourceLoader} able to load {@link Properties} using
* {@link Properties#loadFromXML(java.io.InputStream)}
*
* @return
*/
public static ResourceLoader<Properties> xmlPropertiesLoader() {
return InputStreamPropertiesLoader.XML;
}
private static interface PropertiesLoader extends ResourceLoader<Properties> {
@Override | public default Properties load(ByteSource source) throws IOException { |
ogregoire/fror-common | src/main/java/be/fror/common/base/RandomDistribution.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.exp;
import static java.lang.Math.log;
import static java.lang.Math.pow;
import static java.lang.Math.tan;
import java.util.Random; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class RandomDistribution {
/**
*
* @param random
* @return
* @throws NullPointerException if <tt>random</tt> is <tt>null</tt>.
*/
public static RandomDistribution using(Random random) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/base/RandomDistribution.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.exp;
import static java.lang.Math.log;
import static java.lang.Math.pow;
import static java.lang.Math.tan;
import java.util.Random;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class RandomDistribution {
/**
*
* @param random
* @return
* @throws NullPointerException if <tt>random</tt> is <tt>null</tt>.
*/
public static RandomDistribution using(Random random) { | checkNotNull(random); |
ogregoire/fror-common | src/main/java/be/fror/common/base/RandomDistribution.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.exp;
import static java.lang.Math.log;
import static java.lang.Math.pow;
import static java.lang.Math.tan;
import java.util.Random; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class RandomDistribution {
/**
*
* @param random
* @return
* @throws NullPointerException if <tt>random</tt> is <tt>null</tt>.
*/
public static RandomDistribution using(Random random) {
checkNotNull(random);
return new RandomDistribution(random);
}
private final Random random;
private RandomDistribution(Random random) {
this.random = random;
}
/**
* @return a real number uniformly in <tt>[0, 1)</tt>.
*/
public double uniform() {
return random.nextDouble();
}
/**
* @param n
* @return an integer uniformly in <tt>[0, n)</tt>
* @throws IllegalArgumentException if <tt>n <= 0</tt>
*/
public int uniform(int n) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
//
// Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkNotNull(@Nullable T reference) {
// if (reference != null) {
// return reference;
// } else {
// throw new NullPointerException();
// }
// }
// Path: src/main/java/be/fror/common/base/RandomDistribution.java
import static be.fror.common.base.Preconditions.checkArgument;
import static be.fror.common.base.Preconditions.checkNotNull;
import static java.lang.Math.PI;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.exp;
import static java.lang.Math.log;
import static java.lang.Math.pow;
import static java.lang.Math.tan;
import java.util.Random;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class RandomDistribution {
/**
*
* @param random
* @return
* @throws NullPointerException if <tt>random</tt> is <tt>null</tt>.
*/
public static RandomDistribution using(Random random) {
checkNotNull(random);
return new RandomDistribution(random);
}
private final Random random;
private RandomDistribution(Random random) {
this.random = random;
}
/**
* @return a real number uniformly in <tt>[0, 1)</tt>.
*/
public double uniform() {
return random.nextDouble();
}
/**
* @param n
* @return an integer uniformly in <tt>[0, n)</tt>
* @throws IllegalArgumentException if <tt>n <= 0</tt>
*/
public int uniform(int n) { | checkArgument(n > 0, "n must be positive"); |
ogregoire/fror-common | src/main/java/be/fror/common/resource/Resource.java | // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
| import be.fror.common.io.ByteSource;
import java.io.UncheckedIOException;
import java.lang.ref.SoftReference;
import java.util.function.Supplier;
import javax.annotation.concurrent.ThreadSafe; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Loads a resource and returns it or a cached instance of it.
*
* @author Olivier Grégoire
* @param <T>
*/
@ThreadSafe
public final class Resource<T> implements Supplier<T> {
| // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
// Path: src/main/java/be/fror/common/resource/Resource.java
import be.fror.common.io.ByteSource;
import java.io.UncheckedIOException;
import java.lang.ref.SoftReference;
import java.util.function.Supplier;
import javax.annotation.concurrent.ThreadSafe;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Loads a resource and returns it or a cached instance of it.
*
* @author Olivier Grégoire
* @param <T>
*/
@ThreadSafe
public final class Resource<T> implements Supplier<T> {
| private final ByteSource source; |
ogregoire/fror-common | src/main/java/be/fror/common/resource/ResourceLoader.java | // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
| import be.fror.common.io.ByteSource;
import java.io.IOException;
import java.io.UncheckedIOException;
import javax.annotation.Nonnull; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Loads resource from {@link ByteSource}.
*
* @author Olivier Grégoire
* @param <T> The type of the resource being loaded
*/
public interface ResourceLoader<T> {
/**
* Loads a resource from {@code source} but throws an {@code UncheckedIOException} instead of an
* {@code IOException}.
*
* <p>
* This method may not return {@code null}.
*
* <p>
* This method is the same as calling:
*
* <pre>{@code try {
* return load(source);
* } catch (IOException ex) {
* throw new UncheckedIOException(ex);
* }}</pre>
*
* @param <T> the type of the resource being loaded
* @param source the source to load the resource from
* @return the resource
* @throws UncheckedIOException if any issue happens; wraps an {@code IOException}.
*/
@Nonnull | // Path: src/main/java/be/fror/common/io/ByteSource.java
// public abstract class ByteSource {
//
// protected ByteSource() {
// }
//
// public final InputStream openStream() throws UncheckedIOException {
// try {
// return doOpenStream();
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// protected abstract InputStream doOpenStream() throws IOException;
//
// public CharSource asCharSource(Charset charset) {
// return new AsCharSource(checkNotNull(charset));
// }
//
// private class AsCharSource extends CharSource {
//
// private final Charset charset;
//
// private AsCharSource(Charset charset) {
// this.charset = charset;
// }
//
// @Override
// protected Reader doOpenStream() throws IOException {
// return new InputStreamReader(ByteSource.this.doOpenStream(), charset);
// }
//
// @Override
// public String toString() {
// return ByteSource.this.toString() + ".asCharSource(" + charset + ")";
// }
//
// }
//
// public long copyTo(ByteSink sink) throws UncheckedIOException {
// try (InputStream in = doOpenStream();
// OutputStream out = sink.doOpenStream()) {
// return ByteStreams.copy(in, out);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
//
// }
//
// public byte[] read() throws UncheckedIOException {
// try (InputStream in = doOpenStream()) {
// return ByteStreams.toByteArray(in);
// } catch (IOException e) {
// throw new UncheckedIOException(e);
// }
// }
//
// public static ByteSource wrap(byte[] bytes) {
// return new ByteArrayByteSource(checkNotNull(bytes));
// }
//
// private static class ByteArrayByteSource extends ByteSource {
//
// private final byte[] bytes;
//
// public ByteArrayByteSource(byte[] bytes) {
// this.bytes = bytes;
// }
//
// @Override
// protected InputStream doOpenStream() throws IOException {
// return new ByteArrayInputStream(bytes);
// }
//
// @Override
// public String toString() {
// return "ByteSource.wrap(" + "bytes" + ")";
// }
//
// }
//
// public static ByteSource empty() {
// return EmptyByteSource.INSTANCE;
// }
//
// private static final class EmptyByteSource extends ByteArrayByteSource {
//
// private static final EmptyByteSource INSTANCE = new EmptyByteSource();
//
// private EmptyByteSource() {
// super(new byte[0]);
// }
//
// @Override
// public String toString() {
// return "ByteSource.empty()";
// }
// }
//
// }
// Path: src/main/java/be/fror/common/resource/ResourceLoader.java
import be.fror.common.io.ByteSource;
import java.io.IOException;
import java.io.UncheckedIOException;
import javax.annotation.Nonnull;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.resource;
/**
* Loads resource from {@link ByteSource}.
*
* @author Olivier Grégoire
* @param <T> The type of the resource being loaded
*/
public interface ResourceLoader<T> {
/**
* Loads a resource from {@code source} but throws an {@code UncheckedIOException} instead of an
* {@code IOException}.
*
* <p>
* This method may not return {@code null}.
*
* <p>
* This method is the same as calling:
*
* <pre>{@code try {
* return load(source);
* } catch (IOException ex) {
* throw new UncheckedIOException(ex);
* }}</pre>
*
* @param <T> the type of the resource being loaded
* @param source the source to load the resource from
* @return the resource
* @throws UncheckedIOException if any issue happens; wraps an {@code IOException}.
*/
@Nonnull | public default <T> T uncheckedLoad(ByteSource source) throws UncheckedIOException { |
ogregoire/fror-common | src/main/java/be/fror/common/base/MoreArrays.java | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
| import static be.fror.common.base.Preconditions.checkArgument;
import java.lang.reflect.Array; | /*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class MoreArrays {
private MoreArrays() {
}
public static <T> T[] append(T[] array, int currentSize, T element) { | // Path: src/main/java/be/fror/common/base/Preconditions.java
// public static <T> T checkArgument(@Nullable T value, Predicate<? super T> predicate) {
// if (predicate.test(value)) {
// return value;
// } else {
// throw new IllegalArgumentException();
// }
// }
// Path: src/main/java/be/fror/common/base/MoreArrays.java
import static be.fror.common.base.Preconditions.checkArgument;
import java.lang.reflect.Array;
/*
* Copyright 2015 Olivier Grégoire.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package be.fror.common.base;
/**
*
* @author Olivier Grégoire
*/
public final class MoreArrays {
private MoreArrays() {
}
public static <T> T[] append(T[] array, int currentSize, T element) { | checkArgument(currentSize <= array.length); |
cmusatyalab/elijah-provisioning | android/android/src/edu/cmu/cs/cloudlet/android/application/graphics/GNetworkClient.java | // Path: android/android/gen/edu/cmu/cs/cloudlet/android/R.java
// public final class R {
// public static final class attr {
// }
// public static final class drawable {
// public static final int ic_launcher=0x7f020000;
// }
// public static final class id {
// public static final int camera_preview=0x7f060000;
// public static final int cancel_button=0x7f06000a;
// public static final int container=0x7f060007;
// public static final int current_dir_text=0x7f060009;
// public static final int dialog_list_item_title=0x7f060005;
// public static final int fluid_textView=0x7f06000c;
// public static final int fluidgl_view=0x7f06000d;
// public static final int linearLayout1=0x7f060008;
// public static final int login_status_message=0x7f060003;
// public static final int relativeLayout1=0x7f060006;
// public static final int sendButton=0x7f060001;
// public static final int startBatchTest=0x7f060015;
// public static final int synthesisFromOpenStack=0x7f060014;
// public static final int testAsia=0x7f060012;
// public static final int testCloudlet=0x7f06000e;
// public static final int testEU=0x7f060011;
// public static final int testEast=0x7f06000f;
// public static final int testSynthesis=0x7f060013;
// public static final int testWest=0x7f060010;
// public static final int use_this_dir_button=0x7f06000b;
// public static final int webProgress=0x7f060002;
// public static final int webView=0x7f060004;
// }
// public static final class layout {
// public static final int camera=0x7f030000;
// public static final int custom_progress=0x7f030001;
// public static final int dialog_list_item=0x7f030002;
// public static final int filebrowser=0x7f030003;
// public static final int graphics=0x7f030004;
// public static final int graphics_main=0x7f030005;
// public static final int main=0x7f030006;
// public static final int main_reserach=0x7f030007;
// public static final int test_main=0x7f030008;
// }
// public static final class string {
// public static final int app_name=0x7f050000;
// public static final int synthesis_button_title=0x7f050002;
// public static final int synthesis_config_memu_clear=0x7f050004;
// public static final int synthesis_config_memu_setting=0x7f050003;
// public static final int synthesis_label_title=0x7f050001;
// }
// public static final class xml {
// public static final int preferences=0x7f040000;
// }
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
| public void handleMessage(Message msg) {
if (msg.what == GNetworkClient.CONNECTION_ERROR) {
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.NETWORK_ERROR) {
if (networkClient != null) {
networkClient.close();
}
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.PROGRESS_MESSAGE) {
Bundle data = msg.getData();
activity.updateData(msg.obj);
if(messageUpdateRateCount++ % 10 ==0){
activity.updateLog(data.getString("message"));
}
} else if (msg.what == GNetworkClient.FINISH_MESSAGE){
Bundle data = msg.getData();
// activity.updateLog(data.getString("message") + "\n");
if (networkClient != null) {
networkClient.close();
}
showAlertDialog("Finish");
}
}
};
private void showAlertDialog(String errorMsg) {
if (activity.isFinishing() == false) {
new AlertDialog.Builder(mContext).setTitle("Info")
| // Path: android/android/gen/edu/cmu/cs/cloudlet/android/R.java
// public final class R {
// public static final class attr {
// }
// public static final class drawable {
// public static final int ic_launcher=0x7f020000;
// }
// public static final class id {
// public static final int camera_preview=0x7f060000;
// public static final int cancel_button=0x7f06000a;
// public static final int container=0x7f060007;
// public static final int current_dir_text=0x7f060009;
// public static final int dialog_list_item_title=0x7f060005;
// public static final int fluid_textView=0x7f06000c;
// public static final int fluidgl_view=0x7f06000d;
// public static final int linearLayout1=0x7f060008;
// public static final int login_status_message=0x7f060003;
// public static final int relativeLayout1=0x7f060006;
// public static final int sendButton=0x7f060001;
// public static final int startBatchTest=0x7f060015;
// public static final int synthesisFromOpenStack=0x7f060014;
// public static final int testAsia=0x7f060012;
// public static final int testCloudlet=0x7f06000e;
// public static final int testEU=0x7f060011;
// public static final int testEast=0x7f06000f;
// public static final int testSynthesis=0x7f060013;
// public static final int testWest=0x7f060010;
// public static final int use_this_dir_button=0x7f06000b;
// public static final int webProgress=0x7f060002;
// public static final int webView=0x7f060004;
// }
// public static final class layout {
// public static final int camera=0x7f030000;
// public static final int custom_progress=0x7f030001;
// public static final int dialog_list_item=0x7f030002;
// public static final int filebrowser=0x7f030003;
// public static final int graphics=0x7f030004;
// public static final int graphics_main=0x7f030005;
// public static final int main=0x7f030006;
// public static final int main_reserach=0x7f030007;
// public static final int test_main=0x7f030008;
// }
// public static final class string {
// public static final int app_name=0x7f050000;
// public static final int synthesis_button_title=0x7f050002;
// public static final int synthesis_config_memu_clear=0x7f050004;
// public static final int synthesis_config_memu_setting=0x7f050003;
// public static final int synthesis_label_title=0x7f050001;
// }
// public static final class xml {
// public static final int preferences=0x7f040000;
// }
// }
// Path: android/android/src/edu/cmu/cs/cloudlet/android/application/graphics/GNetworkClient.java
import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
public void handleMessage(Message msg) {
if (msg.what == GNetworkClient.CONNECTION_ERROR) {
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.NETWORK_ERROR) {
if (networkClient != null) {
networkClient.close();
}
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.PROGRESS_MESSAGE) {
Bundle data = msg.getData();
activity.updateData(msg.obj);
if(messageUpdateRateCount++ % 10 ==0){
activity.updateLog(data.getString("message"));
}
} else if (msg.what == GNetworkClient.FINISH_MESSAGE){
Bundle data = msg.getData();
// activity.updateLog(data.getString("message") + "\n");
if (networkClient != null) {
networkClient.close();
}
showAlertDialog("Finish");
}
}
};
private void showAlertDialog(String errorMsg) {
if (activity.isFinishing() == false) {
new AlertDialog.Builder(mContext).setTitle("Info")
| .setIcon(R.drawable.ic_launcher).setMessage(errorMsg)
|
cmusatyalab/elijah-provisioning | android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/FileDialog.java | // Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/FileDialog.java
// public interface FireHandler<L> {
// void fireEvent(L listener);
// }
| import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import edu.cmu.cs.cloudlet.application.esvmtrainer.util.ListenerList.FireHandler;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Environment;
import android.util.Log; |
public void addFileListener(FileSelectedListener listener) {
fileListenerList.add(listener);
}
public void removeFileListener(FileSelectedListener listener) {
fileListenerList.remove(listener);
}
public void setSelectDirectoryOption(boolean selectDirectoryOption) {
this.selectDirectoryOption = selectDirectoryOption;
}
public void addDirectoryListener(DirectorySelectedListener listener) {
dirListenerList.add(listener);
}
public void removeDirectoryListener(DirectorySelectedListener listener) {
dirListenerList.remove(listener);
}
/**
* Show file dialog
*/
public void showDialog() {
createFileDialog().show();
}
private void fireFileSelectedEvent(final File file) {
fileListenerList | // Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/FileDialog.java
// public interface FireHandler<L> {
// void fireEvent(L listener);
// }
// Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/FileDialog.java
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import edu.cmu.cs.cloudlet.application.esvmtrainer.util.ListenerList.FireHandler;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Environment;
import android.util.Log;
public void addFileListener(FileSelectedListener listener) {
fileListenerList.add(listener);
}
public void removeFileListener(FileSelectedListener listener) {
fileListenerList.remove(listener);
}
public void setSelectDirectoryOption(boolean selectDirectoryOption) {
this.selectDirectoryOption = selectDirectoryOption;
}
public void addDirectoryListener(DirectorySelectedListener listener) {
dirListenerList.add(listener);
}
public void removeDirectoryListener(DirectorySelectedListener listener) {
dirListenerList.remove(listener);
}
/**
* Show file dialog
*/
public void showDialog() {
createFileDialog().show();
}
private void fireFileSelectedEvent(final File file) {
fileListenerList | .fireEvent(new FireHandler<FileDialog.FileSelectedListener>() { |
cmusatyalab/elijah-provisioning | android/android_fluid/src/edu/cmu/cs/cloudlet/android/application/graphics/GNetworkClient.java | // Path: android/android/gen/edu/cmu/cs/cloudlet/android/R.java
// public final class R {
// public static final class attr {
// }
// public static final class drawable {
// public static final int ic_launcher=0x7f020000;
// }
// public static final class id {
// public static final int camera_preview=0x7f060000;
// public static final int cancel_button=0x7f06000a;
// public static final int container=0x7f060007;
// public static final int current_dir_text=0x7f060009;
// public static final int dialog_list_item_title=0x7f060005;
// public static final int fluid_textView=0x7f06000c;
// public static final int fluidgl_view=0x7f06000d;
// public static final int linearLayout1=0x7f060008;
// public static final int login_status_message=0x7f060003;
// public static final int relativeLayout1=0x7f060006;
// public static final int sendButton=0x7f060001;
// public static final int startBatchTest=0x7f060015;
// public static final int synthesisFromOpenStack=0x7f060014;
// public static final int testAsia=0x7f060012;
// public static final int testCloudlet=0x7f06000e;
// public static final int testEU=0x7f060011;
// public static final int testEast=0x7f06000f;
// public static final int testSynthesis=0x7f060013;
// public static final int testWest=0x7f060010;
// public static final int use_this_dir_button=0x7f06000b;
// public static final int webProgress=0x7f060002;
// public static final int webView=0x7f060004;
// }
// public static final class layout {
// public static final int camera=0x7f030000;
// public static final int custom_progress=0x7f030001;
// public static final int dialog_list_item=0x7f030002;
// public static final int filebrowser=0x7f030003;
// public static final int graphics=0x7f030004;
// public static final int graphics_main=0x7f030005;
// public static final int main=0x7f030006;
// public static final int main_reserach=0x7f030007;
// public static final int test_main=0x7f030008;
// }
// public static final class string {
// public static final int app_name=0x7f050000;
// public static final int synthesis_button_title=0x7f050002;
// public static final int synthesis_config_memu_clear=0x7f050004;
// public static final int synthesis_config_memu_setting=0x7f050003;
// public static final int synthesis_label_title=0x7f050001;
// }
// public static final class xml {
// public static final int preferences=0x7f040000;
// }
// }
| import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
| public void handleMessage(Message msg) {
if (msg.what == GNetworkClient.CONNECTION_ERROR) {
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.NETWORK_ERROR) {
if (networkClient != null) {
networkClient.close();
}
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.PROGRESS_MESSAGE) {
Bundle data = msg.getData();
activity.updateData(msg.obj);
if(messageUpdateRateCount++ % 10 ==0){
activity.updateLog(data.getString("message"));
}
} else if (msg.what == GNetworkClient.FINISH_MESSAGE){
Bundle data = msg.getData();
// activity.updateLog(data.getString("message") + "\n");
if (networkClient != null) {
networkClient.close();
}
showAlertDialog("Finish");
}
}
};
private void showAlertDialog(String errorMsg) {
if (activity.isFinishing() == false) {
new AlertDialog.Builder(mContext).setTitle("Info")
| // Path: android/android/gen/edu/cmu/cs/cloudlet/android/R.java
// public final class R {
// public static final class attr {
// }
// public static final class drawable {
// public static final int ic_launcher=0x7f020000;
// }
// public static final class id {
// public static final int camera_preview=0x7f060000;
// public static final int cancel_button=0x7f06000a;
// public static final int container=0x7f060007;
// public static final int current_dir_text=0x7f060009;
// public static final int dialog_list_item_title=0x7f060005;
// public static final int fluid_textView=0x7f06000c;
// public static final int fluidgl_view=0x7f06000d;
// public static final int linearLayout1=0x7f060008;
// public static final int login_status_message=0x7f060003;
// public static final int relativeLayout1=0x7f060006;
// public static final int sendButton=0x7f060001;
// public static final int startBatchTest=0x7f060015;
// public static final int synthesisFromOpenStack=0x7f060014;
// public static final int testAsia=0x7f060012;
// public static final int testCloudlet=0x7f06000e;
// public static final int testEU=0x7f060011;
// public static final int testEast=0x7f06000f;
// public static final int testSynthesis=0x7f060013;
// public static final int testWest=0x7f060010;
// public static final int use_this_dir_button=0x7f06000b;
// public static final int webProgress=0x7f060002;
// public static final int webView=0x7f060004;
// }
// public static final class layout {
// public static final int camera=0x7f030000;
// public static final int custom_progress=0x7f030001;
// public static final int dialog_list_item=0x7f030002;
// public static final int filebrowser=0x7f030003;
// public static final int graphics=0x7f030004;
// public static final int graphics_main=0x7f030005;
// public static final int main=0x7f030006;
// public static final int main_reserach=0x7f030007;
// public static final int test_main=0x7f030008;
// }
// public static final class string {
// public static final int app_name=0x7f050000;
// public static final int synthesis_button_title=0x7f050002;
// public static final int synthesis_config_memu_clear=0x7f050004;
// public static final int synthesis_config_memu_setting=0x7f050003;
// public static final int synthesis_label_title=0x7f050001;
// }
// public static final class xml {
// public static final int preferences=0x7f040000;
// }
// }
// Path: android/android_fluid/src/edu/cmu/cs/cloudlet/android/application/graphics/GNetworkClient.java
import java.io.File;
import java.util.ArrayList;
import java.util.Vector;
import org.apache.http.util.ByteArrayBuffer;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.android.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;
public void handleMessage(Message msg) {
if (msg.what == GNetworkClient.CONNECTION_ERROR) {
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.NETWORK_ERROR) {
if (networkClient != null) {
networkClient.close();
}
String message = msg.getData().getString("message");
showAlertDialog(message);
} else if (msg.what == GNetworkClient.PROGRESS_MESSAGE) {
Bundle data = msg.getData();
activity.updateData(msg.obj);
if(messageUpdateRateCount++ % 10 ==0){
activity.updateLog(data.getString("message"));
}
} else if (msg.what == GNetworkClient.FINISH_MESSAGE){
Bundle data = msg.getData();
// activity.updateLog(data.getString("message") + "\n");
if (networkClient != null) {
networkClient.close();
}
showAlertDialog("Finish");
}
}
};
private void showAlertDialog(String errorMsg) {
if (activity.isFinishing() == false) {
new AlertDialog.Builder(mContext).setTitle("Info")
| .setIcon(R.drawable.ic_launcher).setMessage(errorMsg)
|
cmusatyalab/elijah-provisioning | android/android/src/edu/cmu/cs/cloudlet/android/network/NetworkClientSender.java | // Path: android/android/src/edu/cmu/cs/cloudlet/android/data/Measure.java
// public class Measure {
// private static final String SEPERATOR = ":";
// public static final String OVERLAY_TRANSFER_START = "OVERLAY_TRANSFER_START";
// public static final String OVERLAY_TRANSFER_END = "OVERLAY_TRANSFER_END";
// public static final String VM_LAUNCHED = "VM_LAUNCHED";
// public static final String APP_START = "APP_START";
// public static final String APP_END = "APP_END";
//
// protected static Vector<String> timeline;
// protected static long imageSize = 0, memorySize = 0;
//
// public static void clear() {
// timeline = new Vector<String>();
// }
//
// public static void record(String timeString) {
// // timeline.add(timeString + SEPERATOR
// // + (System.currentTimeMillis() / 1000));
// // Log.d("krha", "Measurement : " + timeString + SEPERATOR +
// // System.currentTimeMillis());
// }
//
// public static void setOverlaySize(long imgSize, long memSize) {
// imageSize = imgSize;
// memorySize = memSize;
// }
//
// public static String print() {
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < timeline.size(); i++) {
// sb.append(timeline.get(i) + "\n");
// }
// return sb.toString();
// }
// }
//
// Path: android/android/src/edu/cmu/cs/cloudlet/android/util/KLog.java
// public class KLog {
// public static final String TAG = "krha";
// private static final SimpleDateFormat TIMESTAMP_FMT = new SimpleDateFormat("[HH:mm:ss]");
// private static Writer mWriter;
//
// static{
// File basePath = CloudletEnv.instance().getFilePath(CloudletEnv.ROOT_DIR);
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
// File f = new File(basePath + df.format(new Date()) + ".log");
// String mPath = f.getAbsolutePath();
// try {
// mWriter = new BufferedWriter(new FileWriter(mPath), 2048);
// println("Start logging.");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static void println(String message) {
// Log.d(TAG, message);
// if(mWriter != null){
// try {
// mWriter.write(TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void printErr(String message) {
// Log.e(TAG, message);
// StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
// for(int i = 0; i < stackTraces.length; i++){
// StackTraceElement stackTraceElement = stackTraces[i];
// Log.e(TAG, stackTraceElement.toString());
// }
// if(mWriter != null){
// try {
// mWriter.write("[ERROR] " + TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void close() throws IOException {
// mWriter.close();
// }
// }
| import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Vector;
import edu.cmu.cs.cloudlet.android.data.Measure;
import edu.cmu.cs.cloudlet.android.data.VMInfo;
import edu.cmu.cs.cloudlet.android.util.KLog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
| this.networkWriter = networkWriter;
this.mHandler = handler;
}
// this is only for sending status of VM transfer.
// I know this is bad approach, but make my life easier.
// Do not use this method for other usage.
public void setConnector(CloudletConnector connector) {
this.connector = connector;
}
public void run() {
while (isThreadRun == true) {
if (commandQueue.size() == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
NetworkMsg networkCommand = commandQueue.remove(0);
try {
this.sendCommand(this.networkWriter, networkCommand);
switch (networkCommand.getCommandType()) {
case NetworkMsg.MESSAGE_COMMAND_SEND_META:
// Send overlay meta file
File metaFile = networkCommand.getSelectedFile();
| // Path: android/android/src/edu/cmu/cs/cloudlet/android/data/Measure.java
// public class Measure {
// private static final String SEPERATOR = ":";
// public static final String OVERLAY_TRANSFER_START = "OVERLAY_TRANSFER_START";
// public static final String OVERLAY_TRANSFER_END = "OVERLAY_TRANSFER_END";
// public static final String VM_LAUNCHED = "VM_LAUNCHED";
// public static final String APP_START = "APP_START";
// public static final String APP_END = "APP_END";
//
// protected static Vector<String> timeline;
// protected static long imageSize = 0, memorySize = 0;
//
// public static void clear() {
// timeline = new Vector<String>();
// }
//
// public static void record(String timeString) {
// // timeline.add(timeString + SEPERATOR
// // + (System.currentTimeMillis() / 1000));
// // Log.d("krha", "Measurement : " + timeString + SEPERATOR +
// // System.currentTimeMillis());
// }
//
// public static void setOverlaySize(long imgSize, long memSize) {
// imageSize = imgSize;
// memorySize = memSize;
// }
//
// public static String print() {
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < timeline.size(); i++) {
// sb.append(timeline.get(i) + "\n");
// }
// return sb.toString();
// }
// }
//
// Path: android/android/src/edu/cmu/cs/cloudlet/android/util/KLog.java
// public class KLog {
// public static final String TAG = "krha";
// private static final SimpleDateFormat TIMESTAMP_FMT = new SimpleDateFormat("[HH:mm:ss]");
// private static Writer mWriter;
//
// static{
// File basePath = CloudletEnv.instance().getFilePath(CloudletEnv.ROOT_DIR);
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
// File f = new File(basePath + df.format(new Date()) + ".log");
// String mPath = f.getAbsolutePath();
// try {
// mWriter = new BufferedWriter(new FileWriter(mPath), 2048);
// println("Start logging.");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static void println(String message) {
// Log.d(TAG, message);
// if(mWriter != null){
// try {
// mWriter.write(TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void printErr(String message) {
// Log.e(TAG, message);
// StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
// for(int i = 0; i < stackTraces.length; i++){
// StackTraceElement stackTraceElement = stackTraces[i];
// Log.e(TAG, stackTraceElement.toString());
// }
// if(mWriter != null){
// try {
// mWriter.write("[ERROR] " + TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void close() throws IOException {
// mWriter.close();
// }
// }
// Path: android/android/src/edu/cmu/cs/cloudlet/android/network/NetworkClientSender.java
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Vector;
import edu.cmu.cs.cloudlet.android.data.Measure;
import edu.cmu.cs.cloudlet.android.data.VMInfo;
import edu.cmu.cs.cloudlet.android.util.KLog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
this.networkWriter = networkWriter;
this.mHandler = handler;
}
// this is only for sending status of VM transfer.
// I know this is bad approach, but make my life easier.
// Do not use this method for other usage.
public void setConnector(CloudletConnector connector) {
this.connector = connector;
}
public void run() {
while (isThreadRun == true) {
if (commandQueue.size() == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
NetworkMsg networkCommand = commandQueue.remove(0);
try {
this.sendCommand(this.networkWriter, networkCommand);
switch (networkCommand.getCommandType()) {
case NetworkMsg.MESSAGE_COMMAND_SEND_META:
// Send overlay meta file
File metaFile = networkCommand.getSelectedFile();
| Measure.record(Measure.OVERLAY_TRANSFER_START);
|
cmusatyalab/elijah-provisioning | android/android/src/edu/cmu/cs/cloudlet/android/network/NetworkClientSender.java | // Path: android/android/src/edu/cmu/cs/cloudlet/android/data/Measure.java
// public class Measure {
// private static final String SEPERATOR = ":";
// public static final String OVERLAY_TRANSFER_START = "OVERLAY_TRANSFER_START";
// public static final String OVERLAY_TRANSFER_END = "OVERLAY_TRANSFER_END";
// public static final String VM_LAUNCHED = "VM_LAUNCHED";
// public static final String APP_START = "APP_START";
// public static final String APP_END = "APP_END";
//
// protected static Vector<String> timeline;
// protected static long imageSize = 0, memorySize = 0;
//
// public static void clear() {
// timeline = new Vector<String>();
// }
//
// public static void record(String timeString) {
// // timeline.add(timeString + SEPERATOR
// // + (System.currentTimeMillis() / 1000));
// // Log.d("krha", "Measurement : " + timeString + SEPERATOR +
// // System.currentTimeMillis());
// }
//
// public static void setOverlaySize(long imgSize, long memSize) {
// imageSize = imgSize;
// memorySize = memSize;
// }
//
// public static String print() {
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < timeline.size(); i++) {
// sb.append(timeline.get(i) + "\n");
// }
// return sb.toString();
// }
// }
//
// Path: android/android/src/edu/cmu/cs/cloudlet/android/util/KLog.java
// public class KLog {
// public static final String TAG = "krha";
// private static final SimpleDateFormat TIMESTAMP_FMT = new SimpleDateFormat("[HH:mm:ss]");
// private static Writer mWriter;
//
// static{
// File basePath = CloudletEnv.instance().getFilePath(CloudletEnv.ROOT_DIR);
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
// File f = new File(basePath + df.format(new Date()) + ".log");
// String mPath = f.getAbsolutePath();
// try {
// mWriter = new BufferedWriter(new FileWriter(mPath), 2048);
// println("Start logging.");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static void println(String message) {
// Log.d(TAG, message);
// if(mWriter != null){
// try {
// mWriter.write(TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void printErr(String message) {
// Log.e(TAG, message);
// StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
// for(int i = 0; i < stackTraces.length; i++){
// StackTraceElement stackTraceElement = stackTraces[i];
// Log.e(TAG, stackTraceElement.toString());
// }
// if(mWriter != null){
// try {
// mWriter.write("[ERROR] " + TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void close() throws IOException {
// mWriter.close();
// }
// }
| import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Vector;
import edu.cmu.cs.cloudlet.android.data.Measure;
import edu.cmu.cs.cloudlet.android.data.VMInfo;
import edu.cmu.cs.cloudlet.android.util.KLog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
| public void run() {
while (isThreadRun == true) {
if (commandQueue.size() == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
NetworkMsg networkCommand = commandQueue.remove(0);
try {
this.sendCommand(this.networkWriter, networkCommand);
switch (networkCommand.getCommandType()) {
case NetworkMsg.MESSAGE_COMMAND_SEND_META:
// Send overlay meta file
File metaFile = networkCommand.getSelectedFile();
Measure.record(Measure.OVERLAY_TRANSFER_START);
this.sendBinaryFile(metaFile, false);
break;
case NetworkMsg.MESSAGE_COMMAND_SEND_OVERLAY:
// Send overlay file
File overlayFile = networkCommand.getSelectedFile();
this.sendBinaryFile(overlayFile, true);
this.connector.updateTransferredOverlay(overlayFile);
break;
}
} catch (IOException e) {
| // Path: android/android/src/edu/cmu/cs/cloudlet/android/data/Measure.java
// public class Measure {
// private static final String SEPERATOR = ":";
// public static final String OVERLAY_TRANSFER_START = "OVERLAY_TRANSFER_START";
// public static final String OVERLAY_TRANSFER_END = "OVERLAY_TRANSFER_END";
// public static final String VM_LAUNCHED = "VM_LAUNCHED";
// public static final String APP_START = "APP_START";
// public static final String APP_END = "APP_END";
//
// protected static Vector<String> timeline;
// protected static long imageSize = 0, memorySize = 0;
//
// public static void clear() {
// timeline = new Vector<String>();
// }
//
// public static void record(String timeString) {
// // timeline.add(timeString + SEPERATOR
// // + (System.currentTimeMillis() / 1000));
// // Log.d("krha", "Measurement : " + timeString + SEPERATOR +
// // System.currentTimeMillis());
// }
//
// public static void setOverlaySize(long imgSize, long memSize) {
// imageSize = imgSize;
// memorySize = memSize;
// }
//
// public static String print() {
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < timeline.size(); i++) {
// sb.append(timeline.get(i) + "\n");
// }
// return sb.toString();
// }
// }
//
// Path: android/android/src/edu/cmu/cs/cloudlet/android/util/KLog.java
// public class KLog {
// public static final String TAG = "krha";
// private static final SimpleDateFormat TIMESTAMP_FMT = new SimpleDateFormat("[HH:mm:ss]");
// private static Writer mWriter;
//
// static{
// File basePath = CloudletEnv.instance().getFilePath(CloudletEnv.ROOT_DIR);
// SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmssSSS");
// File f = new File(basePath + df.format(new Date()) + ".log");
// String mPath = f.getAbsolutePath();
// try {
// mWriter = new BufferedWriter(new FileWriter(mPath), 2048);
// println("Start logging.");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public static void println(String message) {
// Log.d(TAG, message);
// if(mWriter != null){
// try {
// mWriter.write(TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void printErr(String message) {
// Log.e(TAG, message);
// StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
// for(int i = 0; i < stackTraces.length; i++){
// StackTraceElement stackTraceElement = stackTraces[i];
// Log.e(TAG, stackTraceElement.toString());
// }
// if(mWriter != null){
// try {
// mWriter.write("[ERROR] " + TIMESTAMP_FMT.format(new Date()));
// mWriter.write(message);
// mWriter.write('\n');
// mWriter.flush();
// } catch (IOException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// public static void close() throws IOException {
// mWriter.close();
// }
// }
// Path: android/android/src/edu/cmu/cs/cloudlet/android/network/NetworkClientSender.java
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Vector;
import edu.cmu.cs.cloudlet.android.data.Measure;
import edu.cmu.cs.cloudlet.android.data.VMInfo;
import edu.cmu.cs.cloudlet.android.util.KLog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
public void run() {
while (isThreadRun == true) {
if (commandQueue.size() == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
}
NetworkMsg networkCommand = commandQueue.remove(0);
try {
this.sendCommand(this.networkWriter, networkCommand);
switch (networkCommand.getCommandType()) {
case NetworkMsg.MESSAGE_COMMAND_SEND_META:
// Send overlay meta file
File metaFile = networkCommand.getSelectedFile();
Measure.record(Measure.OVERLAY_TRANSFER_START);
this.sendBinaryFile(metaFile, false);
break;
case NetworkMsg.MESSAGE_COMMAND_SEND_OVERLAY:
// Send overlay file
File overlayFile = networkCommand.getSelectedFile();
this.sendBinaryFile(overlayFile, true);
this.connector.updateTransferredOverlay(overlayFile);
break;
}
} catch (IOException e) {
| KLog.printErr(e.getMessage());
|
cmusatyalab/elijah-provisioning | android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/network/ESVMNetworkClient.java | // Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/ZipUtility.java
// public class ZipUtility {
//
// public static final void zipFiles(File[] fileList, File zip)
// throws IOException {
// ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
// zip(fileList, zos);
// zos.close();
// }
//
// private static final void zip(File[] files, ZipOutputStream zos)
// throws IOException {
// byte[] buffer = new byte[8192];
// int read = 0;
// for (int i = 0, n = files.length; i < n; i++) {
// FileInputStream in = new FileInputStream(files[i]);
// ZipEntry entry = new ZipEntry(files[i].getName());
// zos.putNextEntry(entry);
// while (-1 != (read = in.read(buffer))) {
// zos.write(buffer, 0, read);
// }
// in.close();
// }
// }
//
// public static final void unzip(File zip, File extractTo) throws IOException {
// ZipFile archive = new ZipFile(zip);
// Enumeration e = archive.entries();
// while (e.hasMoreElements()) {
// ZipEntry entry = (ZipEntry) e.nextElement();
// File file = new File(extractTo, entry.getName());
// if (entry.isDirectory() && !file.exists()) {
// file.mkdirs();
// } else {
// if (!file.getParentFile().exists()) {
// file.getParentFile().mkdirs();
// }
//
// InputStream in = archive.getInputStream(entry);
// BufferedOutputStream out = new BufferedOutputStream(
// new FileOutputStream(file));
//
// byte[] buffer = new byte[8192];
// int read;
//
// while (-1 != (read = in.read(buffer))) {
// out.write(buffer, 0, read);
// }
//
// in.close();
// out.close();
// }
// }
// }
// }
| import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.application.esvmtrainer.util.ZipUtility;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log; | public static final int CALLBACK_FAILED = 0;
public static final int CALLBACK_SUCCESS = 1;
public static final int CALLBACK_UPDATE = 2;
private byte[] binarySendingBuffer = new byte[3 * 1024 * 1024];
private JSONObject header = null;
private File[] imageFiles;
private String serverAddress = null;
private int serverPort = -1;
private Handler networkCallbackHandler = null;
private Socket clientSocket = null;
private DataOutputStream networkWriter = null;
private DataInputStream networkReader = null;
private File outputFile;
public ESVMNetworkClient(Handler handler, JSONObject header, File[] imageFiles, String address, int port) {
this.networkCallbackHandler = handler;
this.header = header;
this.imageFiles = imageFiles;
this.serverAddress = address;
this.serverPort = port;
}
public void run() {
// Zip target files
this.outputFile = null;
File zipDir = imageFiles[0].getParentFile();
try {
this.outputFile = File.createTempFile("ESVMImages", ".zip", zipDir); | // Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/util/ZipUtility.java
// public class ZipUtility {
//
// public static final void zipFiles(File[] fileList, File zip)
// throws IOException {
// ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
// zip(fileList, zos);
// zos.close();
// }
//
// private static final void zip(File[] files, ZipOutputStream zos)
// throws IOException {
// byte[] buffer = new byte[8192];
// int read = 0;
// for (int i = 0, n = files.length; i < n; i++) {
// FileInputStream in = new FileInputStream(files[i]);
// ZipEntry entry = new ZipEntry(files[i].getName());
// zos.putNextEntry(entry);
// while (-1 != (read = in.read(buffer))) {
// zos.write(buffer, 0, read);
// }
// in.close();
// }
// }
//
// public static final void unzip(File zip, File extractTo) throws IOException {
// ZipFile archive = new ZipFile(zip);
// Enumeration e = archive.entries();
// while (e.hasMoreElements()) {
// ZipEntry entry = (ZipEntry) e.nextElement();
// File file = new File(extractTo, entry.getName());
// if (entry.isDirectory() && !file.exists()) {
// file.mkdirs();
// } else {
// if (!file.getParentFile().exists()) {
// file.getParentFile().mkdirs();
// }
//
// InputStream in = archive.getInputStream(entry);
// BufferedOutputStream out = new BufferedOutputStream(
// new FileOutputStream(file));
//
// byte[] buffer = new byte[8192];
// int read;
//
// while (-1 != (read = in.read(buffer))) {
// out.write(buffer, 0, read);
// }
//
// in.close();
// out.close();
// }
// }
// }
// }
// Path: android/android_ESVMTrainer/src/edu/cmu/cs/cloudlet/application/esvmtrainer/network/ESVMNetworkClient.java
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cmu.cs.cloudlet.application.esvmtrainer.util.ZipUtility;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
public static final int CALLBACK_FAILED = 0;
public static final int CALLBACK_SUCCESS = 1;
public static final int CALLBACK_UPDATE = 2;
private byte[] binarySendingBuffer = new byte[3 * 1024 * 1024];
private JSONObject header = null;
private File[] imageFiles;
private String serverAddress = null;
private int serverPort = -1;
private Handler networkCallbackHandler = null;
private Socket clientSocket = null;
private DataOutputStream networkWriter = null;
private DataInputStream networkReader = null;
private File outputFile;
public ESVMNetworkClient(Handler handler, JSONObject header, File[] imageFiles, String address, int port) {
this.networkCallbackHandler = handler;
this.header = header;
this.imageFiles = imageFiles;
this.serverAddress = address;
this.serverPort = port;
}
public void run() {
// Zip target files
this.outputFile = null;
File zipDir = imageFiles[0].getParentFile();
try {
this.outputFile = File.createTempFile("ESVMImages", ".zip", zipDir); | ZipUtility.zipFiles(this.imageFiles, outputFile); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitTag.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
| import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import java.util.Objects;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitTag implements GitTag {
private final JGitRepository repository;
private final String name;
private final Ref ref;
JGitTag(JGitRepository repository, String name, Ref ref) {
this.repository = repository;
this.name = name;
this.ref = ref;
}
@Nonnull
@Override
public String getName() {
return name;
}
@Nonnull
@Override | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitTag.java
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import java.util.Objects;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitTag implements GitTag {
private final JGitRepository repository;
private final String name;
private final Ref ref;
JGitTag(JGitRepository repository, String name, Ref ref) {
this.repository = repository;
this.name = name;
this.ref = ref;
}
@Nonnull
@Override
public String getName() {
return name;
}
@Nonnull
@Override | public GitCommit getTarget() { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContext.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
| import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RuleEvaluationContext {
@Nonnull
Project getProject();
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContext.java
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RuleEvaluationContext {
@Nonnull
Project getProject();
@Nonnull | GitRepository getRepository(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContext.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
| import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RuleEvaluationContext {
@Nonnull
Project getProject();
@Nonnull
GitRepository getRepository();
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContext.java
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RuleEvaluationContext {
@Nonnull
Project getProject();
@Nonnull
GitRepository getRepository();
@Nonnull | MutableSemVersion getVersion(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java
import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId; | private final Supplier<String> commitMessage = Lazy.of(this::readCommitMessage); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId;
private final Supplier<String> commitMessage = Lazy.of(this::readCommitMessage);
JGitCommit(JGitRepository repository, ObjectId objectId) {
this.repository = repository;
this.objectId = objectId;
}
@Nonnull
@Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
| // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java
import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId;
private final Supplier<String> commitMessage = Lazy.of(this::readCommitMessage);
JGitCommit(JGitRepository repository, ObjectId objectId) {
this.repository = repository;
this.objectId = objectId;
}
@Nonnull
@Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
| private <T> T withRevCommit(IOFunction<RevCommit, T> function) { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId;
private final Supplier<String> commitMessage = Lazy.of(this::readCommitMessage);
JGitCommit(JGitRepository repository, ObjectId objectId) {
this.repository = repository;
this.objectId = objectId;
}
@Nonnull
@Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
private <T> T withRevCommit(IOFunction<RevCommit, T> function) { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java
import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitCommit implements GitCommit {
private final JGitRepository repository;
private final ObjectId objectId;
private final Supplier<String> commitMessage = Lazy.of(this::readCommitMessage);
JGitCommit(JGitRepository repository, ObjectId objectId) {
this.repository = repository;
this.objectId = objectId;
}
@Nonnull
@Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
private <T> T withRevCommit(IOFunction<RevCommit, T> function) { | return IOUtils.unchecked(() -> { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream; | @Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
private <T> T withRevCommit(IOFunction<RevCommit, T> function) {
return IOUtils.unchecked(() -> {
try (RevWalk revWalk = new RevWalk(repository.getRepository())) {
RevCommit commit = revWalk.parseCommit(objectId);
return function.apply(commit);
}
});
}
@Nonnull
@Override | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/Lazy.java
// public class Lazy<T> implements Supplier<T> {
//
// private final Supplier<T> supplier;
// private transient volatile boolean initialized = false;
// private transient T value;
//
//
// private Lazy(Supplier<T> supplier) {
// this.supplier = supplier;
// }
//
//
// @Nonnull
// public static <T> Lazy<T> of(Supplier<T> supplier) {
// return new Lazy<>(supplier);
// }
//
//
// @Override
// public T get() {
// if (!initialized) {
// synchronized (this) {
// if (!initialized) {
// T t = supplier.get();
// value = t;
// initialized = true;
// return t;
// }
// }
// }
// return value;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitCommit.java
import com.google.common.collect.Multimap;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.util.Lazy;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Override
public String getId() {
return objectId.name();
}
@Nonnull
@Override
public String getMessage() {
return commitMessage.get();
}
private String readCommitMessage() {
return withRevCommit(RevCommit::getFullMessage);
}
private <T> T withRevCommit(IOFunction<RevCommit, T> function) {
return IOUtils.unchecked(() -> {
try (RevWalk revWalk = new RevWalk(repository.getRepository())) {
RevCommit commit = revWalk.parseCommit(objectId);
return function.apply(commit);
}
});
}
@Nonnull
@Override | public Collection<? extends GitTag> getTags() { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
private SemVersion baseVersion = DEFAULT_BASE_VERSION; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
private SemVersion baseVersion = DEFAULT_BASE_VERSION; | private List<Rule> beforeRules = new ArrayList<>(1); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull; | return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addBeforeRule(Rule rule) {
beforeRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addRule(Rule rule) {
rules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addAfterRule(Rule rule) {
afterRules.add(rule);
return this;
}
@Nonnull
@Override | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addBeforeRule(Rule rule) {
beforeRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addRule(Rule rule) {
rules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addAfterRule(Rule rule) {
afterRules.add(rule);
return this;
}
@Nonnull
@Override | public VersioningRules build() { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull; |
@Nonnull
@Override
public VersioningRulesBuilder addBeforeRule(Rule rule) {
beforeRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addRule(Rule rule) {
rules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addAfterRule(Rule rule) {
afterRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRules build() {
Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules); | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/Rule.java
// public interface Rule {
//
// boolean apply(RuleEvaluationContext evaluationContext);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
// @SuppressWarnings("UnusedReturnValue")
// public interface VersioningRulesBuilder {
//
// @Nonnull
// VersioningRulesBuilder setBaseVersion(SemVersion baseVersion);
//
// @Nonnull
// VersioningRulesBuilder addBeforeRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addRule(Rule rule);
//
// @Nonnull
// VersioningRulesBuilder addAfterRule(Rule rule);
//
// @Nonnull
// VersioningRules build();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRules.java
// public class DefaultVersioningRules implements VersioningRules {
//
// private final Logger logger = Logging.getLogger(getClass());
//
// private final SemVersion baseVersion;
// private final List<Rule> rules;
//
//
// DefaultVersioningRules(SemVersion baseVersion, Iterable<Rule> rules) {
// this.baseVersion = baseVersion;
// this.rules = ImmutableList.copyOf(rules);
// }
//
//
// @Override
// @Nonnull
// public SemVersion evaluate(Project project, GitRepository gitRepository) {
//
// logger.info("Starting rule evaluation");
//
// logger.info("Starting with base version: {}", baseVersion);
// MutableSemVersion version = baseVersion.cloneAsMutable();
// RuleEvaluationContext evaluationContext = new RuleEvaluationContextImpl(project, gitRepository, version);
//
// for (Rule rule : rules) {
//
// SemVersion versionBefore = version.toImmutable();
//
// logger.info("Applying rule: [{}]", rule);
// boolean shouldContinue = rule.apply(evaluationContext);
//
// if (logger.isDebugEnabled()) {
// SemVersion versionAfter = version.toImmutable();
// if (!versionBefore.equals(versionAfter)) {
// logger.debug("Version was modified by rule; is now {}", versionAfter);
// } else {
// logger.debug("Version was not modified by rule");
// }
// }
//
// if (!shouldContinue) {
// logger.info("Skipping evaluation of other rules");
// break;
// }
// }
//
// SemVersion finalVersion = version.toImmutable();
//
// logger.info("Finished rule evaluation; final version is: {}", finalVersion);
//
// return finalVersion;
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
import com.google.common.collect.Iterables;
import org.unbrokendome.gradle.plugins.gitversion.core.Rule;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRules;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
@Nonnull
@Override
public VersioningRulesBuilder addBeforeRule(Rule rule) {
beforeRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addRule(Rule rule) {
rules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRulesBuilder addAfterRule(Rule rule) {
afterRules.add(rule);
return this;
}
@Nonnull
@Override
public VersioningRules build() {
Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules); | return new DefaultVersioningRules(baseVersion, allRules); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DetachedHeadRule.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public final class DetachedHeadRule extends AbstractSimpleRule {
private static final MatchResult MATCH = MatchResult.match("repository is in detached-head mode");
private static final MatchResult MISMATCH = MatchResult.mismatch("repository is not in detached-head mode");
| // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DetachedHeadRule.java
import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public final class DetachedHeadRule extends AbstractSimpleRule {
private static final MatchResult MATCH = MatchResult.match("repository is in detached-head mode");
private static final MatchResult MISMATCH = MatchResult.mismatch("repository is not in detached-head mode");
| DetachedHeadRule(Action<RuleContext> action) { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultRulesContainer.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.*;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class DefaultRulesContainer implements RulesContainer, RulesContainerInternal {
private static final SemVersion DEFAULT_VERSION = SemVersion.create(0, 1, 0);
private final VersioningRulesBuilder versioningRules = VersioningRules.builder(); | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultRulesContainer.java
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.*;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class DefaultRulesContainer implements RulesContainer, RulesContainerInternal {
private static final SemVersion DEFAULT_VERSION = SemVersion.create(0, 1, 0);
private final VersioningRulesBuilder versioningRules = VersioningRules.builder(); | private final MutableSemVersion baseVersion = DEFAULT_VERSION.cloneAsMutable(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/tasks/ShowGitVersion.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import org.gradle.api.internal.ConventionTask;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.io.IOException;
import java.util.Collections; | package org.unbrokendome.gradle.plugins.gitversion.tasks;
/**
* A task that prints the version on standard out.
*
* <p>This task reads the version from the file that was
* written earlier by a {@link DetermineGitVersion} task.
*/
@SuppressWarnings("WeakerAccess")
public class ShowGitVersion extends ConventionTask {
private DetermineGitVersion fromTask;
@Internal
public DetermineGitVersion getFromTask() {
return fromTask;
}
public void setFromTask(DetermineGitVersion fromTask) {
this.fromTask = fromTask;
setDependsOn(Collections.singleton(fromTask));
}
public void from(DetermineGitVersion fromTask) {
setFromTask(fromTask);
}
@TaskAction
public void showGitVersion() throws IOException {
if (fromTask != null) { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/tasks/ShowGitVersion.java
import org.gradle.api.internal.ConventionTask;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.TaskAction;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.io.IOException;
import java.util.Collections;
package org.unbrokendome.gradle.plugins.gitversion.tasks;
/**
* A task that prints the version on standard out.
*
* <p>This task reads the version from the file that was
* written earlier by a {@link DetermineGitVersion} task.
*/
@SuppressWarnings("WeakerAccess")
public class ShowGitVersion extends ConventionTask {
private DetermineGitVersion fromTask;
@Internal
public DetermineGitVersion getFromTask() {
return fromTask;
}
public void setFromTask(DetermineGitVersion fromTask) {
this.fromTask = fromTask;
setDependsOn(Collections.singleton(fromTask));
}
public void from(DetermineGitVersion fromTask) {
setFromTask(fromTask);
}
@TaskAction
public void showGitVersion() throws IOException {
if (fromTask != null) { | SemVersion cachedVersion = fromTask.getCachedVersion(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RulesContainerInternal.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java
// public interface RulesContainer {
//
// @Nonnull
// MutableSemVersion getBaseVersion();
//
//
// default void setBaseVersion(String versionString) {
// SemVersion version = SemVersion.parse(versionString);
// getBaseVersion().setFrom(version);
// }
//
//
// /**
// * Adds a rule that will always be evaluated. It is equivalent to a branch rule whose condition always
// * matches.
// *
// * The rule will be evaluated after any {@code before} rule, and in order of definition regarding other
// * {@code always} or branch rules.
// *
// * @param action an action to configure the rule
// */
// void always(Action<RuleContext> action);
//
//
// /**
// * Adds a rule that will always be evaluated. It is equivalent to a branch rule whose condition always
// * matches.
// *
// * The rule will be evaluated after any {@code before} rule, and in order of definition regarding other
// * {@code always} or branch rules.
// *
// * @param closure a closure to configure the rule
// */
// default void always(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// always(action);
// }
//
//
// void onBranch(String branchName, Action<RuleContext> action);
//
//
// void onBranch(Pattern branchNamePattern, Action<PatternMatchRuleContext> action);
//
//
//
// default void onBranch(Pattern branchNamePattern, @DelegatesTo(PatternMatchRuleContext.class) Closure closure) {
// Action<PatternMatchRuleContext> action = ConfigureUtil.configureUsing(closure);
// onBranch(branchNamePattern, action);
// }
//
//
// default void onBranch(String branchName, @DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// onBranch(branchName, action);
// }
//
//
// void onDetachedHead(Action<RuleContext> action);
//
//
// default void onDetachedHead(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// onDetachedHead(action);
// }
//
//
// void before(Action<RuleContext> action);
//
//
// default void before(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// before(action);
// }
//
//
// void after(Action<RuleContext> action);
//
//
// default void after(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// after(action);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
| import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.RulesContainer;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RulesContainerInternal extends RulesContainer {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java
// public interface RulesContainer {
//
// @Nonnull
// MutableSemVersion getBaseVersion();
//
//
// default void setBaseVersion(String versionString) {
// SemVersion version = SemVersion.parse(versionString);
// getBaseVersion().setFrom(version);
// }
//
//
// /**
// * Adds a rule that will always be evaluated. It is equivalent to a branch rule whose condition always
// * matches.
// *
// * The rule will be evaluated after any {@code before} rule, and in order of definition regarding other
// * {@code always} or branch rules.
// *
// * @param action an action to configure the rule
// */
// void always(Action<RuleContext> action);
//
//
// /**
// * Adds a rule that will always be evaluated. It is equivalent to a branch rule whose condition always
// * matches.
// *
// * The rule will be evaluated after any {@code before} rule, and in order of definition regarding other
// * {@code always} or branch rules.
// *
// * @param closure a closure to configure the rule
// */
// default void always(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// always(action);
// }
//
//
// void onBranch(String branchName, Action<RuleContext> action);
//
//
// void onBranch(Pattern branchNamePattern, Action<PatternMatchRuleContext> action);
//
//
//
// default void onBranch(Pattern branchNamePattern, @DelegatesTo(PatternMatchRuleContext.class) Closure closure) {
// Action<PatternMatchRuleContext> action = ConfigureUtil.configureUsing(closure);
// onBranch(branchNamePattern, action);
// }
//
//
// default void onBranch(String branchName, @DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// onBranch(branchName, action);
// }
//
//
// void onDetachedHead(Action<RuleContext> action);
//
//
// default void onDetachedHead(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// onDetachedHead(action);
// }
//
//
// void before(Action<RuleContext> action);
//
//
// default void before(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// before(action);
// }
//
//
// void after(Action<RuleContext> action);
//
//
// default void after(@DelegatesTo(RuleContext.class) Closure closure) {
// Action<RuleContext> action = ConfigureUtil.configureUsing(closure);
// after(action);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
// public interface VersioningRules {
//
// @Nonnull
// SemVersion evaluate(Project project, GitRepository gitRepository);
//
// @Nonnull
// static VersioningRulesBuilder builder() {
// return new DefaultVersioningRulesBuilder();
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RulesContainerInternal.java
import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.RulesContainer;
import org.unbrokendome.gradle.plugins.gitversion.core.VersioningRules;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public interface RulesContainerInternal extends RulesContainer {
@Nonnull | VersioningRules getVersioningRules(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.util.ConfigureUtil;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface RulesContainer {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.util.ConfigureUtil;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface RulesContainer {
@Nonnull | MutableSemVersion getBaseVersion(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.util.ConfigureUtil;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface RulesContainer {
@Nonnull
MutableSemVersion getBaseVersion();
default void setBaseVersion(String versionString) { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RulesContainer.java
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.util.ConfigureUtil;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface RulesContainer {
@Nonnull
MutableSemVersion getBaseVersion();
default void setBaseVersion(String versionString) { | SemVersion version = SemVersion.parse(versionString); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitBranch.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Objects; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitBranch implements GitBranch {
private final JGitRepository repository;
private final Ref ref;
JGitBranch(JGitRepository repository, Ref ref) {
this.repository = repository;
this.ref = ref;
}
@Nonnull
@Override
public String getShortName() {
String fullName = getFullName();
if (fullName.startsWith(Constants.R_HEADS)) {
return fullName.substring(Constants.R_HEADS.length());
} else if (fullName.startsWith(Constants.R_REMOTES)) {
return fullName.substring(Constants.R_REMOTES.length());
} else {
return fullName;
}
}
@Nonnull
@Override
public String getFullName() {
return ref.getName();
}
@Nonnull
@Override | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitBranch.java
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Objects;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitBranch implements GitBranch {
private final JGitRepository repository;
private final Ref ref;
JGitBranch(JGitRepository repository, Ref ref) {
this.repository = repository;
this.ref = ref;
}
@Nonnull
@Override
public String getShortName() {
String fullName = getFullName();
if (fullName.startsWith(Constants.R_HEADS)) {
return fullName.substring(Constants.R_HEADS.length());
} else if (fullName.startsWith(Constants.R_REMOTES)) {
return fullName.substring(Constants.R_REMOTES.length());
} else {
return fullName;
}
}
@Nonnull
@Override
public String getFullName() {
return ref.getName();
}
@Nonnull
@Override | public GitCommit getHead() { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitBranch.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Objects; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitBranch implements GitBranch {
private final JGitRepository repository;
private final Ref ref;
JGitBranch(JGitRepository repository, Ref ref) {
this.repository = repository;
this.ref = ref;
}
@Nonnull
@Override
public String getShortName() {
String fullName = getFullName();
if (fullName.startsWith(Constants.R_HEADS)) {
return fullName.substring(Constants.R_HEADS.length());
} else if (fullName.startsWith(Constants.R_REMOTES)) {
return fullName.substring(Constants.R_REMOTES.length());
} else {
return fullName;
}
}
@Nonnull
@Override
public String getFullName() {
return ref.getName();
}
@Nonnull
@Override
public GitCommit getHead() { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitBranch.java
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
import javax.annotation.Nonnull;
import java.util.Objects;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitBranch implements GitBranch {
private final JGitRepository repository;
private final Ref ref;
JGitBranch(JGitRepository repository, Ref ref) {
this.repository = repository;
this.ref = ref;
}
@Nonnull
@Override
public String getShortName() {
String fullName = getFullName();
if (fullName.startsWith(Constants.R_HEADS)) {
return fullName.substring(Constants.R_HEADS.length());
} else if (fullName.startsWith(Constants.R_REMOTES)) {
return fullName.substring(Constants.R_REMOTES.length());
} else {
return fullName;
}
}
@Nonnull
@Override
public String getFullName() {
return ref.getName();
}
@Nonnull
@Override
public GitCommit getHead() { | ObjectId objectId = IOUtils.unchecked(() -> ref.getLeaf().getObjectId()); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchNameRule.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchNameRule extends AbstractSimpleRule {
private final String branchName;
| // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchNameRule.java
import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchNameRule extends AbstractSimpleRule {
private final String branchName;
| BranchNameRule(String branchName, Action<RuleContext> action) { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchNameRule.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchNameRule extends AbstractSimpleRule {
private final String branchName;
BranchNameRule(String branchName, Action<RuleContext> action) {
super(action);
this.branchName = branchName;
}
@Nonnull
@Override
protected MatchResult match(RuleEvaluationContext evaluationContext) {
| // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/RuleContext.java
// public interface RuleContext {
//
// @Nonnull
// MutableSemVersion getVersion();
//
//
// default void setVersion(SemVersion version) {
// getVersion().setFrom(version);
// }
//
//
// default void setVersion(String versionString) {
// getVersion().setFrom(versionString);
// }
//
// /**
// * Gets the Gradle project.
// *
// * @return the Gradle {@link Project}
// */
// @Nonnull
// Project getProject();
//
// /**
// * Gets the Git repository.
// *
// * @return the {@link GitRepository}
// */
// @Nonnull
// GitRepository getRepository();
//
// /**
// * Gets the current HEAD commit.
// *
// * @return the current HEAD as a {@link GitCommit}, or {@code null} if the repository is empty
// */
// @Nullable
// default GitCommit getHead() {
// return getRepository().getHead();
// }
//
// boolean isSkipOtherRules();
//
// void setSkipOtherRules(boolean skipOtherRules);
//
// @Nullable
// default GitBranch getCurrentBranch() {
// return getRepository().getCurrentBranch();
// }
//
// /**
// * Gets the <em>short</em> name of the current branch, i.e. the branch that the HEAD points to.
// * Returns {@code null} if the repository is in "detached head" state.
// *
// * <p>The short branch name does not include the {@code refs/heads/} prefix.</p>
// *
// * @return the short name of the current branch
// */
// @Nullable
// default String getBranchName() {
// GitBranch branch = getCurrentBranch();
// return branch != null ? branch.getShortName() : null;
// }
//
//
// @Nullable
// default BranchPoint branchPoint() {
// String masterBranch = Constants.R_REMOTES + Constants.DEFAULT_REMOTE_NAME + "/" + Constants.MASTER;
// return branchPoint(masterBranch);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(String... otherBranchNames) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNames);
// }
//
//
// @Nullable
// default BranchPoint branchPoint(Pattern otherBranchNamePattern) {
// return new GitOperations(getRepository()).branchPoint(otherBranchNamePattern);
// }
//
//
// default int countCommitsSince(HasObjectId obj) {
// return countCommitsSince(obj, false);
// }
//
//
// default int countCommitsSince(HasObjectId obj, boolean countMergeCommits) {
// return new GitOperations(getRepository()).countCommitsSince(obj, countMergeCommits);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern, boolean includeMerges) {
// return new GitOperations(getRepository()).findLatestTag(tagNamePattern, includeMerges);
// }
//
//
// @Nullable
// default TaggedCommit findLatestTag(Pattern tagNamePattern) {
// return findLatestTag(tagNamePattern, true);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchNameRule.java
import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.RuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchNameRule extends AbstractSimpleRule {
private final String branchName;
BranchNameRule(String branchName, Action<RuleContext> action) {
super(action);
this.branchName = branchName;
}
@Nonnull
@Override
protected MatchResult match(RuleEvaluationContext evaluationContext) {
| GitBranch currentBranch = evaluationContext.getRepository().getCurrentBranch(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContextImpl.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
| import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
class RuleEvaluationContextImpl implements RuleEvaluationContext {
private final Project project; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContextImpl.java
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
class RuleEvaluationContextImpl implements RuleEvaluationContext {
private final Project project; | private final GitRepository repository; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContextImpl.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
| import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.internal;
class RuleEvaluationContextImpl implements RuleEvaluationContext {
private final Project project;
private final GitRepository repository; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/MutableSemVersion.java
// public interface MutableSemVersion extends SemVersion {
//
// @Nonnull
// MutableSemVersion setMajor(int major);
//
//
// @Nonnull
// MutableSemVersion addMajor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMajor() {
// return addMajor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setMinor(int minor);
//
//
// @Nonnull
// MutableSemVersion addMinor(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementMinor() {
// return addMinor(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPatch(int patch);
//
//
// @Nonnull
// MutableSemVersion addPatch(int delta);
//
//
// @Nonnull
// default MutableSemVersion incrementPatch() {
// return addPatch(1);
// }
//
//
// @Nonnull
// MutableSemVersion setPrereleaseTag(String prereleaseTag);
//
//
// @Nonnull
// MutableSemVersion setBuildMetadata(String buildMetadata);
//
//
// @Nonnull
// MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata);
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch,
// @Nullable String prereleaseTag) {
// return set(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// default MutableSemVersion set(int major, int minor, int patch) {
// return set(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(SemVersion version) {
// return set(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
//
//
// @Nonnull
// default MutableSemVersion setFrom(String versionString) {
// return setFrom(SemVersion.parse(versionString));
// }
//
//
// @Nonnull
// default SemVersion toImmutable() {
// return new ImmutableSemVersionImpl(
// getMajor(), getMinor(), getPatch(), getPrereleaseTag(), getBuildMetadata());
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/RuleEvaluationContextImpl.java
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.MutableSemVersion;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.internal;
class RuleEvaluationContextImpl implements RuleEvaluationContext {
private final Project project;
private final GitRepository repository; | private final MutableSemVersion version; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/TaggedCommitImpl.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java
// public interface TaggedCommit extends HasObjectId {
//
// @Nonnull
// GitTag getTag();
//
// @Nonnull
// default String getTagName() {
// return getTag().getName();
// }
//
// @Nonnull
// default GitCommit getCommit() {
// return getTag().getTarget();
// }
//
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
//
// @Nonnull
// MatcherFacade getMatches();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
| import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.core.TaggedCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class TaggedCommitImpl implements TaggedCommit {
private final GitTag tag; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java
// public interface TaggedCommit extends HasObjectId {
//
// @Nonnull
// GitTag getTag();
//
// @Nonnull
// default String getTagName() {
// return getTag().getName();
// }
//
// @Nonnull
// default GitCommit getCommit() {
// return getTag().getTarget();
// }
//
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
//
// @Nonnull
// MatcherFacade getMatches();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/TaggedCommitImpl.java
import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.core.TaggedCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class TaggedCommitImpl implements TaggedCommit {
private final GitTag tag; | private final MatcherFacade matches; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/HasObjectId.java
// public interface HasObjectId {
//
// /**
// * Gets the full SHA-256 commit hash for this object.
// * @return the full commit hash
// */
// @Nonnull
// String getId();
//
// /**
// * Gets an abbreviated SHA-256 commit hash for this object.
// * @param length the maximum length of the abbreviated ID
// * @return the abbreviated commit hash
// */
// @Nonnull
// default String id(int length) {
// return getId().substring(0, length);
// }
// }
| import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.model.HasObjectId;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface TaggedCommit extends HasObjectId {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/HasObjectId.java
// public interface HasObjectId {
//
// /**
// * Gets the full SHA-256 commit hash for this object.
// * @return the full commit hash
// */
// @Nonnull
// String getId();
//
// /**
// * Gets an abbreviated SHA-256 commit hash for this object.
// * @param length the maximum length of the abbreviated ID
// * @return the abbreviated commit hash
// */
// @Nonnull
// default String id(int length) {
// return getId().substring(0, length);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.model.HasObjectId;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface TaggedCommit extends HasObjectId {
@Nonnull | GitTag getTag(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/HasObjectId.java
// public interface HasObjectId {
//
// /**
// * Gets the full SHA-256 commit hash for this object.
// * @return the full commit hash
// */
// @Nonnull
// String getId();
//
// /**
// * Gets an abbreviated SHA-256 commit hash for this object.
// * @param length the maximum length of the abbreviated ID
// * @return the abbreviated commit hash
// */
// @Nonnull
// default String id(int length) {
// return getId().substring(0, length);
// }
// }
| import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.model.HasObjectId;
import javax.annotation.Nonnull; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface TaggedCommit extends HasObjectId {
@Nonnull
GitTag getTag();
@Nonnull
default String getTagName() {
return getTag().getName();
}
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitTag.java
// public interface GitTag {
//
// @Nonnull
// String getName();
//
// @Nonnull
// GitCommit getTarget();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/HasObjectId.java
// public interface HasObjectId {
//
// /**
// * Gets the full SHA-256 commit hash for this object.
// * @return the full commit hash
// */
// @Nonnull
// String getId();
//
// /**
// * Gets an abbreviated SHA-256 commit hash for this object.
// * @param length the maximum length of the abbreviated ID
// * @return the abbreviated commit hash
// */
// @Nonnull
// default String id(int length) {
// return getId().substring(0, length);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/TaggedCommit.java
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.model.GitTag;
import org.unbrokendome.gradle.plugins.gitversion.model.HasObjectId;
import javax.annotation.Nonnull;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface TaggedCommit extends HasObjectId {
@Nonnull
GitTag getTag();
@Nonnull
default String getTagName() {
return getTag().getName();
}
@Nonnull | default GitCommit getCommit() { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitRepositoryFactory.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
//
// @Override
// void close();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
//
// CloseableGitRepository getRepository(File dir);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitRepositoryFactory implements GitRepositoryFactory {
private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);
@Override | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
//
// @Override
// void close();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
//
// CloseableGitRepository getRepository(File dir);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitRepositoryFactory.java
import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitRepositoryFactory implements GitRepositoryFactory {
private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);
@Override | public CloseableGitRepository getRepository(File dir) { |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitRepositoryFactory.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
//
// @Override
// void close();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
//
// CloseableGitRepository getRepository(File dir);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitRepositoryFactory implements GitRepositoryFactory {
private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);
@Override
public CloseableGitRepository getRepository(File dir) { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableGitRepository.java
// public interface CloseableGitRepository extends GitRepository, AutoCloseable {
//
// @Override
// void close();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepositoryFactory.java
// public interface GitRepositoryFactory {
//
// CloseableGitRepository getRepository(File dir);
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitRepositoryFactory.java
import java.io.File;
import java.io.IOException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableGitRepository;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepositoryFactory;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitRepositoryFactory implements GitRepositoryFactory {
private final Logger logger = LoggerFactory.getLogger(JGitRepositoryFactory.class);
@Override
public CloseableGitRepository getRepository(File dir) { | return IOUtils.unchecked(() -> doGetRepository(dir)); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java
import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository; | private final IOFunction<RevWalk, RevCommit> firstCommitFunction; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository;
private final IOFunction<RevWalk, RevCommit> firstCommitFunction; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java
import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository;
private final IOFunction<RevWalk, RevCommit> firstCommitFunction; | private final IOBiFunction<RevWalk, RevCommit, RevCommit> nextCommitFunction; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
| import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils; | package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository;
private final IOFunction<RevWalk, RevCommit> firstCommitFunction;
private final IOBiFunction<RevWalk, RevCommit, RevCommit> nextCommitFunction;
private final RevWalk revWalk;
private RevCommit currentCommit = null;
JGitWalkIterator(JGitRepository repository, | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
//
// // do not throw checked Exceptions
// @Override
// void close();
//
// static <E> CloseableIterator<E> emptyIterator() {
// return new CloseableIterator<E>() {
// @Override
// public void close() {
// }
//
//
// @Override
// public boolean hasNext() {
// return false;
// }
//
//
// @Override
// public E next() {
// throw new NoSuchElementException();
// }
// };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
//
// /**
// * Applies this function to the given arguments.
// *
// * @param t the first function argument
// * @param u the second function argument
// * @return the function result
// * @throws IOException for I/O errors
// */
// R apply(T t, U u) throws IOException;
//
// /**
// * Returns a composed function that first applies this function to
// * its input, and then applies the {@code after} function to the result.
// * If evaluation of either function throws an exception, it is relayed to
// * the caller of the composed function.
// *
// * @param <V> the type of output of the {@code after} function, and of the
// * composed function
// * @param after the function to apply after this function is applied
// * @return a composed function that first applies this function and then
// * applies the {@code after} function
// * @throws NullPointerException if after is null
// */
// default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
// Objects.requireNonNull(after);
// return (T t, U u) -> after.apply(apply(t, u));
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
//
// /**
// * Performs this operation on the given argument.
// *
// * @param t the input argument
// * @throws IOException for I/O errors
// */
// void accept(T t) throws IOException;
//
//
// /**
// * Returns a composed {@code IOConsumer} that performs, in sequence, this
// * operation followed by the {@code after} operation. If performing either
// * operation throws an exception, it is relayed to the caller of the
// * composed operation. If performing this operation throws an exception,
// * the {@code after} operation will not be performed.
// *
// * @param after the operation to perform after this operation
// * @return a composed {@code IOConsumer} that performs in sequence this
// * operation followed by the {@code after} operation
// * @throws NullPointerException if {@code after} is null
// */
// default IOConsumer<T> andThen(IOConsumer<? super T> after) {
// Objects.requireNonNull(after);
// return (T t) -> { accept(t); after.accept(t); };
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
//
// R apply(T t) throws IOException;
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
//
// private IOUtils() { }
//
// public static <T> T unchecked(IOCallable<T> callable) {
// try {
// return callable.call();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
//
// public static void unchecked(IORunnable runnable) {
// try {
// runnable.run();
// } catch (IOException ex) {
// throw new RuntimeIOException(ex);
// }
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java
import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;
public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {
private final JGitRepository repository;
private final IOFunction<RevWalk, RevCommit> firstCommitFunction;
private final IOBiFunction<RevWalk, RevCommit, RevCommit> nextCommitFunction;
private final RevWalk revWalk;
private RevCommit currentCommit = null;
JGitWalkIterator(JGitRepository repository, | IOConsumer<RevWalk> revWalkInitializer, |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/PatternMatchingBranchRule.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/PatternMatchRuleContext.java
// public interface PatternMatchRuleContext extends RuleContext {
//
// @Nonnull
// MatcherFacade getMatches();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.PatternMatchRuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public final class PatternMatchingBranchRule extends AbstractRule<PatternMatchRuleContext> {
private final Pattern pattern;
PatternMatchingBranchRule(Pattern pattern, Action<PatternMatchRuleContext> action) {
super(action);
this.pattern = pattern;
}
@Nonnull
@Override
protected MatchResult match(RuleEvaluationContext evaluationContext) { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/PatternMatchRuleContext.java
// public interface PatternMatchRuleContext extends RuleContext {
//
// @Nonnull
// MatcherFacade getMatches();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/PatternMatchingBranchRule.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import org.gradle.api.Action;
import org.unbrokendome.gradle.plugins.gitversion.core.PatternMatchRuleContext;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public final class PatternMatchingBranchRule extends AbstractRule<PatternMatchRuleContext> {
private final Pattern pattern;
PatternMatchingBranchRule(Pattern pattern, Action<PatternMatchRuleContext> action) {
super(action);
this.pattern = pattern;
}
@Nonnull
@Override
protected MatchResult match(RuleEvaluationContext evaluationContext) { | GitBranch currentBranch = evaluationContext.getRepository().getCurrentBranch(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull | SemVersion evaluate(Project project, GitRepository gitRepository); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull | SemVersion evaluate(Project project, GitRepository gitRepository); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion; | package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull
SemVersion evaluate(Project project, GitRepository gitRepository);
@Nonnull
static VersioningRulesBuilder builder() { | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/DefaultVersioningRulesBuilder.java
// public class DefaultVersioningRulesBuilder implements VersioningRulesBuilder {
//
// private static final SemVersion DEFAULT_BASE_VERSION = SemVersion.create(0, 1, 0);
//
// private SemVersion baseVersion = DEFAULT_BASE_VERSION;
// private List<Rule> beforeRules = new ArrayList<>(1);
// private List<Rule> rules = new ArrayList<>(5);
// private List<Rule> afterRules = new ArrayList<>(1);
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder setBaseVersion(SemVersion baseVersion) {
// this.baseVersion = SemVersion.immutableCopyOf(baseVersion);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addBeforeRule(Rule rule) {
// beforeRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addRule(Rule rule) {
// rules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRulesBuilder addAfterRule(Rule rule) {
// afterRules.add(rule);
// return this;
// }
//
//
// @Nonnull
// @Override
// public VersioningRules build() {
// Iterable<Rule> allRules = Iterables.concat(beforeRules, rules, afterRules);
// return new DefaultVersioningRules(baseVersion, allRules);
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitRepository.java
// public interface GitRepository extends AutoCloseable {
//
// File getWorkingDir();
//
// @Nullable
// GitCommit getHead();
//
// @Nullable
// GitBranch getCurrentBranch();
//
// @Nullable
// GitBranch getBranch(String name);
//
// @Nonnull
// Collection<? extends GitBranch> getBranches();
//
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// @Nonnull
// Set<String> getRemoteNames();
//
// @Nonnull
// CloseableIterator<GitCommit> walk(GitCommit startCommit, WalkMode mode);
//
// default CloseableIterator<GitCommit> walk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> walk(WalkMode walkMode) {
// GitCommit head = getHead();
// if (head == null) {
// return CloseableIterator.emptyIterator();
// }
// return walk(getHead(), walkMode);
// }
//
// default CloseableIterator<GitCommit> walk() {
// return walk(WalkMode.ALL);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk(GitCommit startCommit) {
// return walk(startCommit, WalkMode.FIRST_PARENT_ONLY);
// }
//
// default CloseableIterator<GitCommit> firstParentWalk() {
// return walk(WalkMode.FIRST_PARENT_ONLY);
// }
//
// enum WalkMode {
// ALL,
// FIRST_PARENT_ONLY
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRules.java
import javax.annotation.Nonnull;
import org.gradle.api.Project;
import org.unbrokendome.gradle.plugins.gitversion.internal.DefaultVersioningRulesBuilder;
import org.unbrokendome.gradle.plugins.gitversion.model.GitRepository;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
package org.unbrokendome.gradle.plugins.gitversion.core;
public interface VersioningRules {
@Nonnull
SemVersion evaluate(Project project, GitRepository gitRepository);
@Nonnull
static VersioningRulesBuilder builder() { | return new DefaultVersioningRulesBuilder(); |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchPointImpl.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/BranchPoint.java
// public interface BranchPoint extends HasObjectId {
//
// /**
// * Gets the commit from which the branch was created.
// * @return the Git commit
// */
// @Nonnull
// GitCommit getCommit();
//
// /**
// * Gets the other branch which was forked off here.
// * @return the other branch
// */
// @Nonnull
// GitBranch getOtherBranch();
//
// /**
// * Gets the name of the other branch which was forked off here.
// * @return the (short) name of the other branch
// */
// @Nonnull
// default String getOtherBranchName() {
// return getOtherBranch().getShortName();
// }
//
// /**
// * If a regular expression pattern was used to find this branch point, gets the matches
// * from the branch name.
// * @return the matches
// */
// @Nonnull
// MatcherFacade getMatches();
//
// /**
// * Gets the commit ID.
// * @return the commit ID
// */
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
| import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.BranchPoint;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchPointImpl implements BranchPoint {
private final GitCommit commit; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/BranchPoint.java
// public interface BranchPoint extends HasObjectId {
//
// /**
// * Gets the commit from which the branch was created.
// * @return the Git commit
// */
// @Nonnull
// GitCommit getCommit();
//
// /**
// * Gets the other branch which was forked off here.
// * @return the other branch
// */
// @Nonnull
// GitBranch getOtherBranch();
//
// /**
// * Gets the name of the other branch which was forked off here.
// * @return the (short) name of the other branch
// */
// @Nonnull
// default String getOtherBranchName() {
// return getOtherBranch().getShortName();
// }
//
// /**
// * If a regular expression pattern was used to find this branch point, gets the matches
// * from the branch name.
// * @return the matches
// */
// @Nonnull
// MatcherFacade getMatches();
//
// /**
// * Gets the commit ID.
// * @return the commit ID
// */
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchPointImpl.java
import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.BranchPoint;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchPointImpl implements BranchPoint {
private final GitCommit commit; | private final GitBranch otherBranch; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchPointImpl.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/BranchPoint.java
// public interface BranchPoint extends HasObjectId {
//
// /**
// * Gets the commit from which the branch was created.
// * @return the Git commit
// */
// @Nonnull
// GitCommit getCommit();
//
// /**
// * Gets the other branch which was forked off here.
// * @return the other branch
// */
// @Nonnull
// GitBranch getOtherBranch();
//
// /**
// * Gets the name of the other branch which was forked off here.
// * @return the (short) name of the other branch
// */
// @Nonnull
// default String getOtherBranchName() {
// return getOtherBranch().getShortName();
// }
//
// /**
// * If a regular expression pattern was used to find this branch point, gets the matches
// * from the branch name.
// * @return the matches
// */
// @Nonnull
// MatcherFacade getMatches();
//
// /**
// * Gets the commit ID.
// * @return the commit ID
// */
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
| import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.BranchPoint;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit; | package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchPointImpl implements BranchPoint {
private final GitCommit commit;
private final GitBranch otherBranch; | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/BranchPoint.java
// public interface BranchPoint extends HasObjectId {
//
// /**
// * Gets the commit from which the branch was created.
// * @return the Git commit
// */
// @Nonnull
// GitCommit getCommit();
//
// /**
// * Gets the other branch which was forked off here.
// * @return the other branch
// */
// @Nonnull
// GitBranch getOtherBranch();
//
// /**
// * Gets the name of the other branch which was forked off here.
// * @return the (short) name of the other branch
// */
// @Nonnull
// default String getOtherBranchName() {
// return getOtherBranch().getShortName();
// }
//
// /**
// * If a regular expression pattern was used to find this branch point, gets the matches
// * from the branch name.
// * @return the matches
// */
// @Nonnull
// MatcherFacade getMatches();
//
// /**
// * Gets the commit ID.
// * @return the commit ID
// */
// @Nonnull
// @Override
// default String getId() {
// return getCommit().getId();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/MatcherFacade.java
// public interface MatcherFacade extends Iterable<String> {
//
// /**
// * Gets the number of matches.
// * @return the number of matches
// */
// int size();
//
// /**
// * Gets the input subsequence captured by the given group during the match operation.
// *
// * Capturing groups start at index one. The match at index 0 contains the entire input sequence
// * that was matched.
// *
// * @param groupIndex the index of the capturing group
// * @return the input subsequence captured by the given group
// * @see java.util.regex.Matcher#group(int)
// */
// @Nonnull
// String getAt(int groupIndex);
//
// /**
// * Gets the input subsequence captured by the given named group during the match operation.
// *
// * @param groupName the name of a capturing group
// * @return the input subsequence of the given group
// * @see java.util.regex.Matcher#group(String)
// */
// @Nonnull
// String getAt(String groupName);
//
// /**
// * Returns a list containing all capturing results.
// *
// * @return a list containing the group capture results, as if returned by {@link #getAt(int)}
// */
// @Nonnull
// default List<String> toList() {
// int size = size();
// ImmutableList.Builder<String> items = ImmutableList.builder();
// for (int i = 0; i < size; i++) {
// items.add(getAt(i));
// }
// return items.build();
// }
//
//
// @Override
// @Nonnull
// default Iterator<String> iterator() {
// return toList().iterator();
// }
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitBranch.java
// public interface GitBranch {
//
// @Nonnull
// String getShortName();
//
// @Nonnull
// String getFullName();
//
// @Nonnull
// GitCommit getHead();
// }
//
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
//
// @Nonnull
// String getMessage();
//
// /**
// * Gets a collection of all tags in the repository that point to this commit.
// *
// * @return a collection of {@link GitTag} objects (may be empty)
// */
// @Nonnull
// Collection<? extends GitTag> getTags();
//
// /**
// * Gets a list of the parent commits.
// *
// * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
// * parents refer to the merged branch(es).</p>
// *
// * @return the list of parent commits; may be empty
// */
// @Nonnull
// List<? extends GitCommit> getParents();
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/internal/BranchPointImpl.java
import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.core.BranchPoint;
import org.unbrokendome.gradle.plugins.gitversion.core.MatcherFacade;
import org.unbrokendome.gradle.plugins.gitversion.model.GitBranch;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
package org.unbrokendome.gradle.plugins.gitversion.internal;
public class BranchPointImpl implements BranchPoint {
private final GitCommit commit;
private final GitBranch otherBranch; | private final MatcherFacade matches; |
unbroken-dome/gradle-gitversion-plugin | src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
| import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion; | package org.unbrokendome.gradle.plugins.gitversion.core;
@SuppressWarnings("UnusedReturnValue")
public interface VersioningRulesBuilder {
@Nonnull | // Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/version/SemVersion.java
// public interface SemVersion {
//
// int getMajor();
//
// int getMinor();
//
// int getPatch();
//
// @Nullable
// String getPrereleaseTag();
//
// @Nullable
// String getBuildMetadata();
//
//
// @Nonnull
// default MutableSemVersion cloneAsMutable() {
// return new MutableSemVersionImpl()
// .setFrom(this);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch,
// @Nullable String prereleaseTag,
// @Nullable String buildMetadata) {
// return new ImmutableSemVersionImpl(major, minor, patch, prereleaseTag, buildMetadata);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch, String prereleaseTag) {
// return create(major, minor, patch, prereleaseTag, null);
// }
//
//
// @Nonnull
// static SemVersion create(int major, int minor, int patch) {
// return create(major, minor, patch, null, null);
// }
//
//
// @Nonnull
// static SemVersion immutableCopyOf(SemVersion version) {
// if (version instanceof ImmutableSemVersionImpl) {
// return version;
//
// } else {
// return create(version.getMajor(), version.getMinor(), version.getPatch(),
// version.getPrereleaseTag(), version.getBuildMetadata());
// }
// }
//
//
// @Nonnull
// static SemVersion parse(String input) {
// return SemVersionParser.parse(input);
// }
// }
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/core/VersioningRulesBuilder.java
import javax.annotation.Nonnull;
import org.unbrokendome.gradle.plugins.gitversion.version.SemVersion;
package org.unbrokendome.gradle.plugins.gitversion.core;
@SuppressWarnings("UnusedReturnValue")
public interface VersioningRulesBuilder {
@Nonnull | VersioningRulesBuilder setBaseVersion(SemVersion baseVersion); |
jsptest/jsptest | jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCasePageAssertions.java | // Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/ExpectedAssertionFailure.java
// public abstract class ExpectedAssertionFailure {
//
// private HtmlTestCase testcase;
//
// /**
// * Override this method to perform a test that should fail with an exception.
// */
// protected abstract void run() throws Exception;
//
// /**
// * @param testcase
// * The <tt>HtmlTestCase</tt> that serves as the context for this operation.
// */
// public ExpectedAssertionFailure(HtmlTestCase testcase) throws Exception {
// this(testcase, "Operation should've failed but it didn't.");
// }
//
// /**
// * @param testcase
// * The <tt>HtmlTestCase</tt> that serves as the context for this operation.
// * @param message
// * The message to display if the specified operation doesn't throw an
// * AssertionFailedError.
// */
// public ExpectedAssertionFailure(HtmlTestCase testcase, String message) throws Exception {
// this.testcase = testcase;
// verify(message);
// }
//
// /**
// * Gives access to a <tt>PageAssertion</tt> object, enabling page-oriented (HTML) assertions.
// */
// protected PageAssertion page() {
// return testcase.page();
// }
//
// /**
// * Gives access to an <tt>OutputAssertion</tt> object, enabling raw output-oriented
// * assertions.
// */
// protected OutputAssertion output() {
// return testcase.output();
// }
//
// /**
// * Gives access to an <tt>ElementAssertion</tt> object for the HTML element identified by the
// * given XPath expression.
// *
// * @param xpath
// * @return
// */
// protected ElementAssertion element(String xpath) {
// return testcase.element(xpath);
// }
//
// private void verify(String message) {
// try {
// run();
// throw new NoExceptionWasThrown();
// } catch (AssertionFailedError expected) {
// // everything went according to the plan!
// } catch (NoExceptionWasThrown e) {
// throw new AssertionFailedError(message);
// } catch (Throwable e) {
// throw new IncorrectExceptionError("A non-assertion exception was thrown: "
// + e.getClass().getName(), e);
// }
// }
//
// /**
// * Thrown from an assertion method indicating that the wrong kind of exception was thrown by the
// * code under test.
// *
// * @author Lasse Koskela
// */
// public static class IncorrectExceptionError extends RuntimeException {
//
// public IncorrectExceptionError(String message, Throwable e) {
// super(message, e);
// }
// }
//
// /**
// * Thrown from an assertion method indicating that no exception was thrown by the code under
// * test against the expectations. This class is only used internally and is never passed to
// * client code (test written by a JspTest user).
// *
// * @author Lasse Koskela
// */
// private static class NoExceptionWasThrown extends Exception {
// }
// }
| import net.sf.jsptest.assertion.ExpectedAssertionFailure;
| /*
* Copyright 2007 Lasse Koskela.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sf.jsptest;
/**
* @author Lasse Koskela
*/
public class TestHtmlTestCasePageAssertions extends AbstractHtmlTestCaseTestCase {
protected void appendOutput(StringBuffer h) {
h.append("<html><head>");
h.append("<title>PageTitle</title>");
h.append("</head><body>");
h.append("before div");
h.append("<!-- this is inside a comment -->");
h.append("<div>");
h.append(" inside div");
h.append("</div>");
h.append("after div");
h.append("</body></html>");
}
public void testPageShouldHaveTitle() throws Exception {
testcase.page().shouldHaveTitle("PageTitle");
| // Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/ExpectedAssertionFailure.java
// public abstract class ExpectedAssertionFailure {
//
// private HtmlTestCase testcase;
//
// /**
// * Override this method to perform a test that should fail with an exception.
// */
// protected abstract void run() throws Exception;
//
// /**
// * @param testcase
// * The <tt>HtmlTestCase</tt> that serves as the context for this operation.
// */
// public ExpectedAssertionFailure(HtmlTestCase testcase) throws Exception {
// this(testcase, "Operation should've failed but it didn't.");
// }
//
// /**
// * @param testcase
// * The <tt>HtmlTestCase</tt> that serves as the context for this operation.
// * @param message
// * The message to display if the specified operation doesn't throw an
// * AssertionFailedError.
// */
// public ExpectedAssertionFailure(HtmlTestCase testcase, String message) throws Exception {
// this.testcase = testcase;
// verify(message);
// }
//
// /**
// * Gives access to a <tt>PageAssertion</tt> object, enabling page-oriented (HTML) assertions.
// */
// protected PageAssertion page() {
// return testcase.page();
// }
//
// /**
// * Gives access to an <tt>OutputAssertion</tt> object, enabling raw output-oriented
// * assertions.
// */
// protected OutputAssertion output() {
// return testcase.output();
// }
//
// /**
// * Gives access to an <tt>ElementAssertion</tt> object for the HTML element identified by the
// * given XPath expression.
// *
// * @param xpath
// * @return
// */
// protected ElementAssertion element(String xpath) {
// return testcase.element(xpath);
// }
//
// private void verify(String message) {
// try {
// run();
// throw new NoExceptionWasThrown();
// } catch (AssertionFailedError expected) {
// // everything went according to the plan!
// } catch (NoExceptionWasThrown e) {
// throw new AssertionFailedError(message);
// } catch (Throwable e) {
// throw new IncorrectExceptionError("A non-assertion exception was thrown: "
// + e.getClass().getName(), e);
// }
// }
//
// /**
// * Thrown from an assertion method indicating that the wrong kind of exception was thrown by the
// * code under test.
// *
// * @author Lasse Koskela
// */
// public static class IncorrectExceptionError extends RuntimeException {
//
// public IncorrectExceptionError(String message, Throwable e) {
// super(message, e);
// }
// }
//
// /**
// * Thrown from an assertion method indicating that no exception was thrown by the code under
// * test against the expectations. This class is only used internally and is never passed to
// * client code (test written by a JspTest user).
// *
// * @author Lasse Koskela
// */
// private static class NoExceptionWasThrown extends Exception {
// }
// }
// Path: jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCasePageAssertions.java
import net.sf.jsptest.assertion.ExpectedAssertionFailure;
/*
* Copyright 2007 Lasse Koskela.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sf.jsptest;
/**
* @author Lasse Koskela
*/
public class TestHtmlTestCasePageAssertions extends AbstractHtmlTestCaseTestCase {
protected void appendOutput(StringBuffer h) {
h.append("<html><head>");
h.append("<title>PageTitle</title>");
h.append("</head><body>");
h.append("before div");
h.append("<!-- this is inside a comment -->");
h.append("<div>");
h.append(" inside div");
h.append("</div>");
h.append("after div");
h.append("</body></html>");
}
public void testPageShouldHaveTitle() throws Exception {
testcase.page().shouldHaveTitle("PageTitle");
| new ExpectedAssertionFailure(testcase) {
|
jsptest/jsptest | jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/Java6Compiler.java | // Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java
// public class IO {
//
// public static byte[] readToByteArray(File file) throws IOException {
// return readToByteArray(new FileInputStream(file));
// }
//
// public static byte[] readToByteArray(InputStream in) throws IOException {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// byte[] buffer = new byte[8096];
// int r = -1;
// while ((r = in.read(buffer)) != -1) {
// out.write(buffer, 0, r);
// }
// in.close();
// return out.toByteArray();
// }
//
// public static void write(String what, File to) throws IOException {
// write(what, new FileWriter(to, false));
// }
//
// public static void append(String what, File to) throws IOException {
// write(what, new FileWriter(to, true));
// }
//
// private static void write(String what, FileWriter to) throws IOException {
// to.write(what);
// to.close();
// }
//
// public static String readToString(File file) throws IOException {
// return new String(readToByteArray(file));
// }
//
// public static String readToString(InputStream stream) throws IOException {
// return new String(readToByteArray(stream));
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import net.sf.jsptest.utils.IO; | package net.sf.jsptest.compiler.java;
public class Java6Compiler extends CommandLineJavac {
private static final String TMPDIR = System.getProperty("java.io.tmpdir");
protected boolean execute(String[] arguments) throws IOException,
InterruptedException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
return executeWithReflection(arguments, output) == 0;
} finally {
File logFile = new File(TMPDIR, getClass().getName() + ".log"); | // Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java
// public class IO {
//
// public static byte[] readToByteArray(File file) throws IOException {
// return readToByteArray(new FileInputStream(file));
// }
//
// public static byte[] readToByteArray(InputStream in) throws IOException {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// byte[] buffer = new byte[8096];
// int r = -1;
// while ((r = in.read(buffer)) != -1) {
// out.write(buffer, 0, r);
// }
// in.close();
// return out.toByteArray();
// }
//
// public static void write(String what, File to) throws IOException {
// write(what, new FileWriter(to, false));
// }
//
// public static void append(String what, File to) throws IOException {
// write(what, new FileWriter(to, true));
// }
//
// private static void write(String what, FileWriter to) throws IOException {
// to.write(what);
// to.close();
// }
//
// public static String readToString(File file) throws IOException {
// return new String(readToByteArray(file));
// }
//
// public static String readToString(InputStream stream) throws IOException {
// return new String(readToByteArray(stream));
// }
// }
// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/Java6Compiler.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import net.sf.jsptest.utils.IO;
package net.sf.jsptest.compiler.java;
public class Java6Compiler extends CommandLineJavac {
private static final String TMPDIR = System.getProperty("java.io.tmpdir");
protected boolean execute(String[] arguments) throws IOException,
InterruptedException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
return executeWithReflection(arguments, output) == 0;
} finally {
File logFile = new File(TMPDIR, getClass().getName() + ".log"); | IO.append(output.toString(), logFile); |
jsptest/jsptest | jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/FormFieldAssertion.java | // Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java
// public class Form {
//
// private Element element;
// private NodeList fields;
//
// /**
// * Build a <tt>Form</tt> from an HTML element.
// *
// * @param element
// * The HTML form element to represent.
// */
// public Form(Element element) {
// this.element = element;
// fields = element.getElementsByTagName("INPUT");
// }
//
// /**
// * Returns the name of the HTML form.
// */
// public String getName() {
// return element.getAttribute("NAME");
// }
//
// /**
// * Indicates whether the form has an input field by the given name.
// *
// * @param name
// * The name of the input field.
// */
// public boolean hasInputField(String name) {
// if (getInputField(name) != null) {
// return true;
// }
// return false;
// }
//
// /**
// * Returns the specified input field or <tt>null</tt> if no such field exists on the form.
// *
// * @param name
// * The name of the input field.
// */
// public FormField getInputField(String name) {
// for (int i = 0; i < fields.getLength(); i++) {
// FormField field = new FormField((Element) fields.item(i));
// if (name.equals(field.getName())) {
// return field;
// }
// }
// return null;
// }
//
// /**
// * Indicates whether the form has a submit button by the given name.
// *
// * @param name
// * The name of the submit button.
// */
// public boolean hasSubmitButton(String name) {
// NodeList elems = element.getElementsByTagName("INPUT");
// for (int i = 0; i < elems.getLength(); i++) {
// Element element = (Element) elems.item(i);
// if ("SUBMIT".equalsIgnoreCase(element.getAttribute("TYPE"))) {
// if (name.equals(element.getAttribute("VALUE"))) {
// return true;
// }
// if (name.equals(element.getAttribute("NAME"))) {
// return true;
// }
// }
// }
// return false;
// }
//
// /**
// * Indicates whether the form has a submit button.
// */
// public boolean hasSubmitButton() {
// NodeList elems = element.getElementsByTagName("INPUT");
// for (int i = 0; i < elems.getLength(); i++) {
// Element element = (Element) elems.item(i);
// if ("SUBMIT".equalsIgnoreCase(element.getAttribute("TYPE"))) {
// return true;
// }
// }
// return false;
// }
// }
//
// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java
// public class FormField {
//
// private Element element;
//
// /**
// * Build an input field from the given HTML element.
// *
// * @param element
// * The HTML input element.
// */
// public FormField(Element element) {
// this.element = element;
// }
//
// /**
// * Returns the name of the field.
// */
// public String getName() {
// return element.getAttribute("NAME");
// }
//
// /**
// * Returns the value of the field.
// */
// public String getValue() {
// return element.getAttribute("VALUE");
// }
// }
| import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.Assert;
import net.sf.jsptest.html.Form;
import net.sf.jsptest.html.FormField; | package net.sf.jsptest.assertion;
/**
* Provides form field-oriented assertion methods.
*
* @author Lasse Koskela
*/
public class FormFieldAssertion {
private final List fields;
private final String fieldName;
/**
* @param forms
* The list of forms that should be considered the context for the subsequent
* assertion methods.
* @param fieldName
* The name of the form field that should be considered the context for the
* subsequent assertion methods.
*/
public FormFieldAssertion(List forms, String fieldName) {
this.fieldName = fieldName;
this.fields = new ArrayList();
for (Iterator i = forms.iterator(); i.hasNext();) { | // Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java
// public class Form {
//
// private Element element;
// private NodeList fields;
//
// /**
// * Build a <tt>Form</tt> from an HTML element.
// *
// * @param element
// * The HTML form element to represent.
// */
// public Form(Element element) {
// this.element = element;
// fields = element.getElementsByTagName("INPUT");
// }
//
// /**
// * Returns the name of the HTML form.
// */
// public String getName() {
// return element.getAttribute("NAME");
// }
//
// /**
// * Indicates whether the form has an input field by the given name.
// *
// * @param name
// * The name of the input field.
// */
// public boolean hasInputField(String name) {
// if (getInputField(name) != null) {
// return true;
// }
// return false;
// }
//
// /**
// * Returns the specified input field or <tt>null</tt> if no such field exists on the form.
// *
// * @param name
// * The name of the input field.
// */
// public FormField getInputField(String name) {
// for (int i = 0; i < fields.getLength(); i++) {
// FormField field = new FormField((Element) fields.item(i));
// if (name.equals(field.getName())) {
// return field;
// }
// }
// return null;
// }
//
// /**
// * Indicates whether the form has a submit button by the given name.
// *
// * @param name
// * The name of the submit button.
// */
// public boolean hasSubmitButton(String name) {
// NodeList elems = element.getElementsByTagName("INPUT");
// for (int i = 0; i < elems.getLength(); i++) {
// Element element = (Element) elems.item(i);
// if ("SUBMIT".equalsIgnoreCase(element.getAttribute("TYPE"))) {
// if (name.equals(element.getAttribute("VALUE"))) {
// return true;
// }
// if (name.equals(element.getAttribute("NAME"))) {
// return true;
// }
// }
// }
// return false;
// }
//
// /**
// * Indicates whether the form has a submit button.
// */
// public boolean hasSubmitButton() {
// NodeList elems = element.getElementsByTagName("INPUT");
// for (int i = 0; i < elems.getLength(); i++) {
// Element element = (Element) elems.item(i);
// if ("SUBMIT".equalsIgnoreCase(element.getAttribute("TYPE"))) {
// return true;
// }
// }
// return false;
// }
// }
//
// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java
// public class FormField {
//
// private Element element;
//
// /**
// * Build an input field from the given HTML element.
// *
// * @param element
// * The HTML input element.
// */
// public FormField(Element element) {
// this.element = element;
// }
//
// /**
// * Returns the name of the field.
// */
// public String getName() {
// return element.getAttribute("NAME");
// }
//
// /**
// * Returns the value of the field.
// */
// public String getValue() {
// return element.getAttribute("VALUE");
// }
// }
// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/FormFieldAssertion.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.Assert;
import net.sf.jsptest.html.Form;
import net.sf.jsptest.html.FormField;
package net.sf.jsptest.assertion;
/**
* Provides form field-oriented assertion methods.
*
* @author Lasse Koskela
*/
public class FormFieldAssertion {
private final List fields;
private final String fieldName;
/**
* @param forms
* The list of forms that should be considered the context for the subsequent
* assertion methods.
* @param fieldName
* The name of the form field that should be considered the context for the
* subsequent assertion methods.
*/
public FormFieldAssertion(List forms, String fieldName) {
this.fieldName = fieldName;
this.fields = new ArrayList();
for (Iterator i = forms.iterator(); i.hasNext();) { | Form form = (Form) i.next(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.