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
|
---|---|---|---|---|---|---|
cmullins/song_recognition
|
src/java/org/sidoh/song_recognition/signature/ManuallyBucketizedFrequencyBandsStarBuffer.java
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
|
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
import org.sidoh.collections.Pair;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.EvenFrequencyBandsStarBuffer.Builder;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
|
public ManuallyBucketizedFrequencyBandsStarBuffer.Builder manuallyBanded(double[] bandSizes, double[] bandWeights) {
this.bandSizes = bandSizes;
this.bandWeights = bandWeights;
return this;
}
@Override
public ManuallyBucketizedFrequencyBandsStarBuffer.Builder fairlyBanded() {
return this.manuallyBanded(fairSizes, fairWeights);
}
}
// Multiple references to the same objects to optimize performance.
private final StarBuffer[] innerBuffers;
// A plain ol' list of all of the inner star buffers
private final Collection<StarBuffer> innerBufferList;
private final StarBuffer.Builder innerBuilder;
public ManuallyBucketizedFrequencyBandsStarBuffer(double starDensityFactor,
double[] bandSizes,
double[] bandWeights,
StarBuffer.Builder innerBuilder,
Spectrogram spec) {
super(spec);
this.innerBuilder = innerBuilder;
this.innerBuffers = new StarBuffer[spec.getBinFloors().length];
this.innerBufferList = new ArrayList<StarBuffer>(bandSizes.length);
// Compute the end indexes of the bands given the percentage sizes
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
// Path: src/java/org/sidoh/song_recognition/signature/ManuallyBucketizedFrequencyBandsStarBuffer.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
import org.sidoh.collections.Pair;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.EvenFrequencyBandsStarBuffer.Builder;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
public ManuallyBucketizedFrequencyBandsStarBuffer.Builder manuallyBanded(double[] bandSizes, double[] bandWeights) {
this.bandSizes = bandSizes;
this.bandWeights = bandWeights;
return this;
}
@Override
public ManuallyBucketizedFrequencyBandsStarBuffer.Builder fairlyBanded() {
return this.manuallyBanded(fairSizes, fairWeights);
}
}
// Multiple references to the same objects to optimize performance.
private final StarBuffer[] innerBuffers;
// A plain ol' list of all of the inner star buffers
private final Collection<StarBuffer> innerBufferList;
private final StarBuffer.Builder innerBuilder;
public ManuallyBucketizedFrequencyBandsStarBuffer(double starDensityFactor,
double[] bandSizes,
double[] bandWeights,
StarBuffer.Builder innerBuilder,
Spectrogram spec) {
super(spec);
this.innerBuilder = innerBuilder;
this.innerBuffers = new StarBuffer[spec.getBinFloors().length];
this.innerBufferList = new ArrayList<StarBuffer>(bandSizes.length);
// Compute the end indexes of the bands given the percentage sizes
|
Deque<Pair<Double, Integer>> buckets = new LinkedList<Pair<Double, Integer>>();
|
cmullins/song_recognition
|
src/java/org/sidoh/song_recognition/signature/ManuallyBucketizedFrequencyBandsStarBuffer.java
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
|
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
import org.sidoh.collections.Pair;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.EvenFrequencyBandsStarBuffer.Builder;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
|
for (int i = 0; i < bandSizes.length; i++) {
int nextStart = lastStart + (int)(bandSizes[i] * innerBuffers.length);
double density = bandWeights[i] * starDensityFactor;
buckets.addLast(Pair.create(density, nextStart));
lastStart = nextStart;
}
if (buckets.peekLast().getV2() < innerBuffers.length) {
Pair<Double, Integer> old = buckets.pollLast();
buckets.addLast(Pair.create(old.getV1(), innerBuffers.length));
}
StarBuffer currentBuffer = getStarBuffer(buckets.peekFirst());
innerBufferList.add(currentBuffer);
for (int i = 0; i < innerBuffers.length; i++) {
if (i >= buckets.peekFirst().getV2()) {
buckets.pollFirst();
currentBuffer = getStarBuffer(buckets.peekFirst());
innerBufferList.add(currentBuffer);
}
innerBuffers[i] = currentBuffer;
}
}
protected StarBuffer getStarBuffer(Pair<Double, Integer> bucket) {
return innerBuilder.starDensityFactor(bucket.getV1()).create(spec);
}
@Override
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
// Path: src/java/org/sidoh/song_recognition/signature/ManuallyBucketizedFrequencyBandsStarBuffer.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
import org.sidoh.collections.Pair;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.signature.EvenFrequencyBandsStarBuffer.Builder;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
for (int i = 0; i < bandSizes.length; i++) {
int nextStart = lastStart + (int)(bandSizes[i] * innerBuffers.length);
double density = bandWeights[i] * starDensityFactor;
buckets.addLast(Pair.create(density, nextStart));
lastStart = nextStart;
}
if (buckets.peekLast().getV2() < innerBuffers.length) {
Pair<Double, Integer> old = buckets.pollLast();
buckets.addLast(Pair.create(old.getV1(), innerBuffers.length));
}
StarBuffer currentBuffer = getStarBuffer(buckets.peekFirst());
innerBufferList.add(currentBuffer);
for (int i = 0; i < innerBuffers.length; i++) {
if (i >= buckets.peekFirst().getV2()) {
buckets.pollFirst();
currentBuffer = getStarBuffer(buckets.peekFirst());
innerBufferList.add(currentBuffer);
}
innerBuffers[i] = currentBuffer;
}
}
protected StarBuffer getStarBuffer(Pair<Double, Integer> bucket) {
return innerBuilder.starDensityFactor(bucket.getV1()).create(spec);
}
@Override
|
public void offerStar(Star s) {
|
cmullins/song_recognition
|
src/java/org/sidoh/song_recognition/signature/ConstellationMapExtractor.java
|
// Path: src/java/org/sidoh/peak_detection/StatefulPeakDetector.java
// public abstract class StatefulPeakDetector implements ValueListener {
//
// public abstract static class Builder {
// public abstract StatefulPeakDetector create(PeakListener peaks);
//
// public Builder withSmoothingFunction(StatefulSmoothingFunction.Builder smoothingFnBuilder) {
// if (smoothingFnBuilder == null) {
// return this;
// }
// else {
// return new StatefulSmoothedPeakDetector.Builder(smoothingFnBuilder, this);
// }
// }
// }
//
// private final PeakListener peaks;
// private int index;
//
// private static int counter = 0;
// protected int count;
//
// public StatefulPeakDetector(PeakListener peaks) {
// this.peaks = peaks;
// this.index = 0;
// count = counter++;
// }
//
// /**
// * Informs the PeakListener that there is a peak at #index.
// *
// * @param index
// */
// protected final void offerPeak(int index, double value) {
// peaks.peakDetected(index, value);
// }
//
// /**
// *
// */
// public final void offerNewValue(double value) {
// handleNewInput(index++, value);
// }
//
// /**
// * Handles a new input value.
// *
// * @param value
// */
// protected abstract void handleNewInput(int index, double value);
//
// /**
// * Get a Builder that creates instances of {@link StatefulSdsFromMeanPeakDetector}
// * with the provided arguments.
// *
// * @param windowWidth
// * @param sds
// * @return
// */
// public static StatefulSdsFromMeanPeakDetector.Builder sdsFromMean(int windowWidth, double sds) {
// return new StatefulSdsFromMeanPeakDetector.Builder(windowWidth, sds);
// }
//
// /**
// * Get a Builder that creates instances of {@link StatefulMeanDeltaPeakDetector}.
// *
// * @param windowWidth
// * @return
// */
// public static StatefulMeanDeltaPeakDetector.Builder meanDelta(int windowWidth) {
// return new StatefulMeanDeltaPeakDetector.Builder(windowWidth);
// }
// }
//
// Path: src/java/org/sidoh/peak_detection/StatelessPeakDetector.java
// public abstract class StatelessPeakDetector {
// /**
// * Accepts a time series and returns the locations within the series that this
// * detector considers peaks. The locations should be 0-indexed from the first
// * thing in the time series.
// *
// * @param series
// * @return
// */
// public abstract Iterable<Integer> findPeaks(Iterable<Double> values);
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
|
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import org.sidoh.io.ProgressNotifier;
import org.sidoh.io.ProgressNotifier.Builder;
import org.sidoh.peak_detection.PeakListener;
import org.sidoh.peak_detection.StatefulPeakDetector;
import org.sidoh.peak_detection.StatelessPeakDetector;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
|
//
// return map;
}
/**
* Get the maximum number of stars per second of audio. This is computed using
* {@link #starDensityFactor}, which is provided in the constructor.
*
* @param spec
* @return
*/
protected int getStarsPerSecond(Spectrogram spec) {
return (int)Math.floor(
(starDensityFactor * spec.getMaxTick())
/
(double)spec.tickToSeconds(spec.getMaxTick()));
}
protected int getMaxStars(Spectrogram spec) {
return (int)Math.floor(starDensityFactor*spec.getMaxTick());
}
/**
*
* @param spec
* @param x
* @param y
* @return
*/
|
// Path: src/java/org/sidoh/peak_detection/StatefulPeakDetector.java
// public abstract class StatefulPeakDetector implements ValueListener {
//
// public abstract static class Builder {
// public abstract StatefulPeakDetector create(PeakListener peaks);
//
// public Builder withSmoothingFunction(StatefulSmoothingFunction.Builder smoothingFnBuilder) {
// if (smoothingFnBuilder == null) {
// return this;
// }
// else {
// return new StatefulSmoothedPeakDetector.Builder(smoothingFnBuilder, this);
// }
// }
// }
//
// private final PeakListener peaks;
// private int index;
//
// private static int counter = 0;
// protected int count;
//
// public StatefulPeakDetector(PeakListener peaks) {
// this.peaks = peaks;
// this.index = 0;
// count = counter++;
// }
//
// /**
// * Informs the PeakListener that there is a peak at #index.
// *
// * @param index
// */
// protected final void offerPeak(int index, double value) {
// peaks.peakDetected(index, value);
// }
//
// /**
// *
// */
// public final void offerNewValue(double value) {
// handleNewInput(index++, value);
// }
//
// /**
// * Handles a new input value.
// *
// * @param value
// */
// protected abstract void handleNewInput(int index, double value);
//
// /**
// * Get a Builder that creates instances of {@link StatefulSdsFromMeanPeakDetector}
// * with the provided arguments.
// *
// * @param windowWidth
// * @param sds
// * @return
// */
// public static StatefulSdsFromMeanPeakDetector.Builder sdsFromMean(int windowWidth, double sds) {
// return new StatefulSdsFromMeanPeakDetector.Builder(windowWidth, sds);
// }
//
// /**
// * Get a Builder that creates instances of {@link StatefulMeanDeltaPeakDetector}.
// *
// * @param windowWidth
// * @return
// */
// public static StatefulMeanDeltaPeakDetector.Builder meanDelta(int windowWidth) {
// return new StatefulMeanDeltaPeakDetector.Builder(windowWidth);
// }
// }
//
// Path: src/java/org/sidoh/peak_detection/StatelessPeakDetector.java
// public abstract class StatelessPeakDetector {
// /**
// * Accepts a time series and returns the locations within the series that this
// * detector considers peaks. The locations should be 0-indexed from the first
// * thing in the time series.
// *
// * @param series
// * @return
// */
// public abstract Iterable<Integer> findPeaks(Iterable<Double> values);
// }
//
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMap.java
// public static class Star implements Serializable {
// private static final long serialVersionUID = 1851275921474044916L;
//
//
// private final double time;
// private final double frequency;
// private final double intensity;
// private final int x;
// private final int y;
//
// public Star(final double time, final double frequency, final double intensity, final int x, final int y) {
// this.time = time;
// this.frequency = frequency;
// this.intensity = intensity;
// this.x = x;
// this.y = y;
// }
//
// public double getTime() {
// return time;
// }
//
// public double getFrequency() {
// return frequency;
// }
//
// public double getIntensity() {
// return intensity;
// }
//
// public int getTick() {
// return x;
// }
//
// public int getBin() {
// return y;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + x;
// result = prime * result + y;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Star other = (Star) obj;
// if (x != other.x)
// return false;
// if (y != other.y)
// return false;
// return true;
// }
//
// @Override
// public String toString() {
// return "Star [x=" + x + ", y=" + y + ", intensity=" + intensity + "]";
// }
// }
// Path: src/java/org/sidoh/song_recognition/signature/ConstellationMapExtractor.java
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import org.sidoh.io.ProgressNotifier;
import org.sidoh.io.ProgressNotifier.Builder;
import org.sidoh.peak_detection.PeakListener;
import org.sidoh.peak_detection.StatefulPeakDetector;
import org.sidoh.peak_detection.StatelessPeakDetector;
import org.sidoh.song_recognition.signature.ConstellationMap.Star;
import org.sidoh.song_recognition.spectrogram.Spectrogram;
//
// return map;
}
/**
* Get the maximum number of stars per second of audio. This is computed using
* {@link #starDensityFactor}, which is provided in the constructor.
*
* @param spec
* @return
*/
protected int getStarsPerSecond(Spectrogram spec) {
return (int)Math.floor(
(starDensityFactor * spec.getMaxTick())
/
(double)spec.tickToSeconds(spec.getMaxTick()));
}
protected int getMaxStars(Spectrogram spec) {
return (int)Math.floor(starDensityFactor*spec.getMaxTick());
}
/**
*
* @param spec
* @param x
* @param y
* @return
*/
|
protected static Star getStar(final Spectrogram spec, final int x, final int y) {
|
cmullins/song_recognition
|
src/java/org/sidoh/song_recognition/benchmark/report/ReportEntry.java
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/io/Serializer.java
// public interface Serializer<T> {
// /**
// * @param object
// * @param out
// * @throws IOException
// */
// public void serialize(T object, OutputStream out) throws IOException;
// }
//
// Path: src/java/org/sidoh/song_recognition/database/SongMetaData.java
// public class SongMetaData implements Serializable {
// private static final long serialVersionUID = -2438398130255866971L;
//
// private String filename;
// private String name;
// private int id;
//
// public SongMetaData(String filename, String name, int id) {
// this.filename = filename;
// this.name = name;
// this.id = id;
// }
//
// public String getFilename() {
// return filename;
// }
//
// public void setFilename(String filename) {
// this.filename = filename;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// }
|
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sidoh.collections.IndexingDictionary;
import org.sidoh.collections.Pair;
import org.sidoh.io.Serializer;
import org.sidoh.song_recognition.database.SignatureDatabase.QueryResponse;
import org.sidoh.song_recognition.database.SongMetaData;
import org.sidoh.song_recognition.signature.StarHashSignature;
|
package org.sidoh.song_recognition.benchmark.report;
public class ReportEntry implements Serializable {
public static final Serializer<ReportEntry> jsonSerializer = new Serializer<ReportEntry>() {
@Override
public void serialize(ReportEntry object, OutputStream out) throws IOException {
// TODO Auto-generated method stub
BufferedWriter b = new BufferedWriter(new OutputStreamWriter(out));
b.append("{");
b.append(String.format("\"clipName\" : \"%s\", ", object.getClipSongPart()));
b.append(String.format("\"clipStart\" : %d,", object.getClipStart()));
b.append(String.format("\"clipEnd\" : %d,", object.getClipEnd()));
b.append(String.format("\"addedNoiseId\" : \"%s\",", object.getNoiseId()));
b.append(String.format("\"matchFound\" : %d,", object.matchFound() ? 1 : 0));
b.append(String.format("\"matchCorrect\" : %d,", object.matchCorrect ? 1 : 0));
b.append(String.format("\"songId\" : \"%s\",", object.getSongId()));
b.append(String.format("\"confidence\" : %.5f,", object.getConfidence()));
b.append(String.format("\"hasSpectrogram\" : %d,", object.hasSpectrogram() ? 1 : 0));
b.append(String.format("\"hasHistograms\" : %d", object.hasHistograms() ? 1 : 0));
if (object.hasSpectrogram()) {
b.append(String.format(",\"spectrogramPath\" : \"%s\"", object.getSpectrogramPath()));
}
if (object.hasHistograms()) {
b.append(String.format(",\"histogramPaths\" : ["));
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/io/Serializer.java
// public interface Serializer<T> {
// /**
// * @param object
// * @param out
// * @throws IOException
// */
// public void serialize(T object, OutputStream out) throws IOException;
// }
//
// Path: src/java/org/sidoh/song_recognition/database/SongMetaData.java
// public class SongMetaData implements Serializable {
// private static final long serialVersionUID = -2438398130255866971L;
//
// private String filename;
// private String name;
// private int id;
//
// public SongMetaData(String filename, String name, int id) {
// this.filename = filename;
// this.name = name;
// this.id = id;
// }
//
// public String getFilename() {
// return filename;
// }
//
// public void setFilename(String filename) {
// this.filename = filename;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// }
// Path: src/java/org/sidoh/song_recognition/benchmark/report/ReportEntry.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sidoh.collections.IndexingDictionary;
import org.sidoh.collections.Pair;
import org.sidoh.io.Serializer;
import org.sidoh.song_recognition.database.SignatureDatabase.QueryResponse;
import org.sidoh.song_recognition.database.SongMetaData;
import org.sidoh.song_recognition.signature.StarHashSignature;
package org.sidoh.song_recognition.benchmark.report;
public class ReportEntry implements Serializable {
public static final Serializer<ReportEntry> jsonSerializer = new Serializer<ReportEntry>() {
@Override
public void serialize(ReportEntry object, OutputStream out) throws IOException {
// TODO Auto-generated method stub
BufferedWriter b = new BufferedWriter(new OutputStreamWriter(out));
b.append("{");
b.append(String.format("\"clipName\" : \"%s\", ", object.getClipSongPart()));
b.append(String.format("\"clipStart\" : %d,", object.getClipStart()));
b.append(String.format("\"clipEnd\" : %d,", object.getClipEnd()));
b.append(String.format("\"addedNoiseId\" : \"%s\",", object.getNoiseId()));
b.append(String.format("\"matchFound\" : %d,", object.matchFound() ? 1 : 0));
b.append(String.format("\"matchCorrect\" : %d,", object.matchCorrect ? 1 : 0));
b.append(String.format("\"songId\" : \"%s\",", object.getSongId()));
b.append(String.format("\"confidence\" : %.5f,", object.getConfidence()));
b.append(String.format("\"hasSpectrogram\" : %d,", object.hasSpectrogram() ? 1 : 0));
b.append(String.format("\"hasHistograms\" : %d", object.hasHistograms() ? 1 : 0));
if (object.hasSpectrogram()) {
b.append(String.format(",\"spectrogramPath\" : \"%s\"", object.getSpectrogramPath()));
}
if (object.hasHistograms()) {
b.append(String.format(",\"histogramPaths\" : ["));
|
Iterator<Entry<String, Pair<Double,String>>> itr = object.getHistograms().entrySet().iterator();
|
cmullins/song_recognition
|
src/java/org/sidoh/song_recognition/benchmark/report/ReportEntry.java
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/io/Serializer.java
// public interface Serializer<T> {
// /**
// * @param object
// * @param out
// * @throws IOException
// */
// public void serialize(T object, OutputStream out) throws IOException;
// }
//
// Path: src/java/org/sidoh/song_recognition/database/SongMetaData.java
// public class SongMetaData implements Serializable {
// private static final long serialVersionUID = -2438398130255866971L;
//
// private String filename;
// private String name;
// private int id;
//
// public SongMetaData(String filename, String name, int id) {
// this.filename = filename;
// this.name = name;
// this.id = id;
// }
//
// public String getFilename() {
// return filename;
// }
//
// public void setFilename(String filename) {
// this.filename = filename;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// }
|
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sidoh.collections.IndexingDictionary;
import org.sidoh.collections.Pair;
import org.sidoh.io.Serializer;
import org.sidoh.song_recognition.database.SignatureDatabase.QueryResponse;
import org.sidoh.song_recognition.database.SongMetaData;
import org.sidoh.song_recognition.signature.StarHashSignature;
|
b.append("]");
}
b.append("}");
b.flush();
}
};
public static final Serializer<ReportEntry> txtSerializer = new Serializer<ReportEntry>() {
@Override
public void serialize(ReportEntry object, OutputStream out) throws IOException {
BufferedWriter b = new BufferedWriter(new OutputStreamWriter(out));
b.append(String.format("%d,%d,%d,%s,%.5f,%d",
object.getSongIndex(),
object.getClipIndex(),
object.getClipLength(),
object.getNoiseId(),
object.getConfidence(),
object.isCorrect() ? 1 : 0));
b.flush();
}
};
private static IndexingDictionary<String> songIndex = new IndexingDictionary<String>();
private static final long serialVersionUID = 6147611654719791675L;
|
// Path: src/java/org/sidoh/collections/Pair.java
// public class Pair<T1, T2> {
// protected T1 v1;
// protected T2 v2;
//
// public Pair(T1 v1, T2 v2) {
// this.v1 = v1;
// this.v2 = v2;
// }
//
// public T1 getV1() {
// return v1;
// }
//
// public void setV1(T1 v1) {
// this.v1 = v1;
// }
//
// public T2 getV2() {
// return v2;
// }
//
// public void setV2(T2 v2) {
// this.v2 = v2;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((v1 == null) ? 0 : v1.hashCode());
// result = prime * result + ((v2 == null) ? 0 : v2.hashCode());
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
// Pair other = (Pair) obj;
// if (v1 == null) {
// if (other.v1 != null)
// return false;
// } else if (!v1.equals(other.v1))
// return false;
// if (v2 == null) {
// if (other.v2 != null)
// return false;
// } else if (!v2.equals(other.v2))
// return false;
// return true;
// }
//
// public String toString() {
// return "(" + v1 + "," + v2 + ")";
// }
//
// public static <T1, T2> Pair<T1, T2> create(T1 v1, T2 v2) {
// return new Pair<T1, T2>(v1, v2);
// }
// }
//
// Path: src/java/org/sidoh/io/Serializer.java
// public interface Serializer<T> {
// /**
// * @param object
// * @param out
// * @throws IOException
// */
// public void serialize(T object, OutputStream out) throws IOException;
// }
//
// Path: src/java/org/sidoh/song_recognition/database/SongMetaData.java
// public class SongMetaData implements Serializable {
// private static final long serialVersionUID = -2438398130255866971L;
//
// private String filename;
// private String name;
// private int id;
//
// public SongMetaData(String filename, String name, int id) {
// this.filename = filename;
// this.name = name;
// this.id = id;
// }
//
// public String getFilename() {
// return filename;
// }
//
// public void setFilename(String filename) {
// this.filename = filename;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// }
// Path: src/java/org/sidoh/song_recognition/benchmark/report/ReportEntry.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sidoh.collections.IndexingDictionary;
import org.sidoh.collections.Pair;
import org.sidoh.io.Serializer;
import org.sidoh.song_recognition.database.SignatureDatabase.QueryResponse;
import org.sidoh.song_recognition.database.SongMetaData;
import org.sidoh.song_recognition.signature.StarHashSignature;
b.append("]");
}
b.append("}");
b.flush();
}
};
public static final Serializer<ReportEntry> txtSerializer = new Serializer<ReportEntry>() {
@Override
public void serialize(ReportEntry object, OutputStream out) throws IOException {
BufferedWriter b = new BufferedWriter(new OutputStreamWriter(out));
b.append(String.format("%d,%d,%d,%s,%.5f,%d",
object.getSongIndex(),
object.getClipIndex(),
object.getClipLength(),
object.getNoiseId(),
object.getConfidence(),
object.isCorrect() ? 1 : 0));
b.flush();
}
};
private static IndexingDictionary<String> songIndex = new IndexingDictionary<String>();
private static final long serialVersionUID = 6147611654719791675L;
|
protected SongMetaData song;
|
ctongfei/progressbar
|
src/main/java/me/tongfei/progressbar/InteractiveConsoleProgressBarConsumer.java
|
// Path: src/main/java/me/tongfei/progressbar/TerminalUtils.java
// public class TerminalUtils {
//
// static final char CARRIAGE_RETURN = '\r';
// static final char ESCAPE_CHAR = '\u001b';
// static final int DEFAULT_TERMINAL_WIDTH = 80;
//
// private static Terminal terminal = null;
// private static boolean cursorMovementSupported = false;
//
// static Queue<ProgressBarConsumer> activeConsumers = new ConcurrentLinkedQueue<>();
//
// synchronized static int getTerminalWidth() {
// Terminal terminal = getTerminal();
// int width = terminal.getWidth();
//
// // Workaround for issue #23 under IntelliJ
// return (width >= 10) ? width : DEFAULT_TERMINAL_WIDTH;
// }
//
// static boolean hasCursorMovementSupport() {
// if (terminal == null)
// terminal = getTerminal();
// return cursorMovementSupported;
// }
//
// synchronized static void closeTerminal() {
// try {
// if (terminal != null) {
// terminal.close();
// terminal = null;
// }
// } catch (IOException ignored) { /* noop */ }
// }
//
// static <T extends ProgressBarConsumer> Stream<T> filterActiveConsumers(Class<T> clazz) {
// return activeConsumers.stream()
// .filter(clazz::isInstance)
// .map(clazz::cast);
// }
//
// static String moveCursorUp(int count) {
// return ESCAPE_CHAR + "[" + count + "A" + CARRIAGE_RETURN;
// }
//
// static String moveCursorDown(int count) {
// return ESCAPE_CHAR + "[" + count + "B" + CARRIAGE_RETURN;
// }
//
// /**
// * <ul>
// * <li>Creating terminal is relatively expensive, usually takes between 5-10ms.
// * <ul>
// * <li>If updateInterval is set under 10ms creating new terminal for on every re-render of progress bar could be a problem.</li>
// * <li>Especially when multiple progress bars are running in parallel.</li>
// * </ul>
// * </li>
// * <li>Another problem with {@link Terminal} is that once created you can create another instance (say from different thread), but this instance will be
// * "dumb". Until previously created terminal will be closed.
// * </li>
// * </ul>
// */
// static Terminal getTerminal() {
// if (terminal == null) {
// try {
// // Issue #42
// // Defaulting to a dumb terminal when a supported terminal can not be correctly created
// // see https://github.com/jline/jline3/issues/291
// terminal = TerminalBuilder.builder().dumb(true).build();
// cursorMovementSupported = (
// terminal.getStringCapability(InfoCmp.Capability.cursor_up) != null &&
// terminal.getStringCapability(InfoCmp.Capability.cursor_down) != null
// );
// } catch (IOException e) {
// throw new RuntimeException("This should never happen! Dumb terminal should have been created.");
// }
// }
// return terminal;
// }
//
// }
|
import java.io.PrintStream;
import static me.tongfei.progressbar.TerminalUtils.*;
|
package me.tongfei.progressbar;
/**
* Progress bar consumer for terminals supporting moving cursor up/down.
* @since 0.9.0
* @author Martin Vehovsky
*/
public class InteractiveConsoleProgressBarConsumer extends ConsoleProgressBarConsumer {
private boolean initialized = false;
private int position = 1;
public InteractiveConsoleProgressBarConsumer(PrintStream out) {
super(out);
}
public InteractiveConsoleProgressBarConsumer(PrintStream out, int predefinedWidth) {
super(out, predefinedWidth);
}
@Override
public void accept(String str) {
String s = StringDisplayUtils.trimDisplayLength(str, getMaxRenderedLength());
if (!initialized) {
|
// Path: src/main/java/me/tongfei/progressbar/TerminalUtils.java
// public class TerminalUtils {
//
// static final char CARRIAGE_RETURN = '\r';
// static final char ESCAPE_CHAR = '\u001b';
// static final int DEFAULT_TERMINAL_WIDTH = 80;
//
// private static Terminal terminal = null;
// private static boolean cursorMovementSupported = false;
//
// static Queue<ProgressBarConsumer> activeConsumers = new ConcurrentLinkedQueue<>();
//
// synchronized static int getTerminalWidth() {
// Terminal terminal = getTerminal();
// int width = terminal.getWidth();
//
// // Workaround for issue #23 under IntelliJ
// return (width >= 10) ? width : DEFAULT_TERMINAL_WIDTH;
// }
//
// static boolean hasCursorMovementSupport() {
// if (terminal == null)
// terminal = getTerminal();
// return cursorMovementSupported;
// }
//
// synchronized static void closeTerminal() {
// try {
// if (terminal != null) {
// terminal.close();
// terminal = null;
// }
// } catch (IOException ignored) { /* noop */ }
// }
//
// static <T extends ProgressBarConsumer> Stream<T> filterActiveConsumers(Class<T> clazz) {
// return activeConsumers.stream()
// .filter(clazz::isInstance)
// .map(clazz::cast);
// }
//
// static String moveCursorUp(int count) {
// return ESCAPE_CHAR + "[" + count + "A" + CARRIAGE_RETURN;
// }
//
// static String moveCursorDown(int count) {
// return ESCAPE_CHAR + "[" + count + "B" + CARRIAGE_RETURN;
// }
//
// /**
// * <ul>
// * <li>Creating terminal is relatively expensive, usually takes between 5-10ms.
// * <ul>
// * <li>If updateInterval is set under 10ms creating new terminal for on every re-render of progress bar could be a problem.</li>
// * <li>Especially when multiple progress bars are running in parallel.</li>
// * </ul>
// * </li>
// * <li>Another problem with {@link Terminal} is that once created you can create another instance (say from different thread), but this instance will be
// * "dumb". Until previously created terminal will be closed.
// * </li>
// * </ul>
// */
// static Terminal getTerminal() {
// if (terminal == null) {
// try {
// // Issue #42
// // Defaulting to a dumb terminal when a supported terminal can not be correctly created
// // see https://github.com/jline/jline3/issues/291
// terminal = TerminalBuilder.builder().dumb(true).build();
// cursorMovementSupported = (
// terminal.getStringCapability(InfoCmp.Capability.cursor_up) != null &&
// terminal.getStringCapability(InfoCmp.Capability.cursor_down) != null
// );
// } catch (IOException e) {
// throw new RuntimeException("This should never happen! Dumb terminal should have been created.");
// }
// }
// return terminal;
// }
//
// }
// Path: src/main/java/me/tongfei/progressbar/InteractiveConsoleProgressBarConsumer.java
import java.io.PrintStream;
import static me.tongfei.progressbar.TerminalUtils.*;
package me.tongfei.progressbar;
/**
* Progress bar consumer for terminals supporting moving cursor up/down.
* @since 0.9.0
* @author Martin Vehovsky
*/
public class InteractiveConsoleProgressBarConsumer extends ConsoleProgressBarConsumer {
private boolean initialized = false;
private int position = 1;
public InteractiveConsoleProgressBarConsumer(PrintStream out) {
super(out);
}
public InteractiveConsoleProgressBarConsumer(PrintStream out, int predefinedWidth) {
super(out, predefinedWidth);
}
@Override
public void accept(String str) {
String s = StringDisplayUtils.trimDisplayLength(str, getMaxRenderedLength());
if (!initialized) {
|
TerminalUtils.filterActiveConsumers(InteractiveConsoleProgressBarConsumer.class).forEach(c -> c.position++);
|
ctongfei/progressbar
|
src/main/java/me/tongfei/progressbar/ProgressBar.java
|
// Path: src/main/java/me/tongfei/progressbar/Util.java
// static ConsoleProgressBarConsumer createConsoleConsumer(int predefinedWidth) {
// PrintStream real = new PrintStream(new FileOutputStream(FileDescriptor.err));
// return createConsoleConsumer(real, predefinedWidth); // System.err might be overridden by System.setErr
// }
|
import me.tongfei.progressbar.wrapped.*;
import static me.tongfei.progressbar.Util.createConsoleConsumer;
import java.io.*;
import java.text.DecimalFormat;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.BaseStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
|
package me.tongfei.progressbar;
/**
* A console-based progress bar with minimal runtime overhead.
* @author Tongfei Chen
*/
public class ProgressBar implements AutoCloseable {
private ProgressState progress;
private ProgressUpdateAction action;
private ScheduledFuture<?> scheduledTask;
/**
* Creates a progress bar with the specific taskName name and initial maximum value.
* @param task Task name
* @param initialMax Initial maximum value
*/
public ProgressBar(String task, long initialMax) {
this(task, initialMax, 1000, false, System.err, ProgressBarStyle.COLORFUL_UNICODE_BLOCK, "", 1, false, null, ChronoUnit.SECONDS, 0L, Duration.ZERO);
}
/**
* Creates a progress bar with the specific taskName name, initial maximum value,
* customized update interval (default 1000 ms), the PrintStream to be used, and output style.
* @param task Task name
* @param initialMax Initial maximum value
* @param updateIntervalMillis Update interval (default value 1000 ms)
* @param continuousUpdate Rerender every time the update interval happens regardless of progress count.
* @param style Output style (default value ProgressBarStyle.UNICODE_BLOCK)
* @param showSpeed Should the calculated speed be displayed
* @param speedFormat Speed number format
* @deprecated Use {@link ProgressBarBuilder} instead.
*/
public ProgressBar(
String task,
long initialMax,
int updateIntervalMillis,
boolean continuousUpdate,
PrintStream os,
ProgressBarStyle style,
String unitName,
long unitSize,
boolean showSpeed,
DecimalFormat speedFormat,
ChronoUnit speedUnit,
long processed,
Duration elapsed
) {
this(task, initialMax, updateIntervalMillis, continuousUpdate, processed, elapsed,
new DefaultProgressBarRenderer(style, unitName, unitSize, showSpeed, speedFormat, speedUnit),
|
// Path: src/main/java/me/tongfei/progressbar/Util.java
// static ConsoleProgressBarConsumer createConsoleConsumer(int predefinedWidth) {
// PrintStream real = new PrintStream(new FileOutputStream(FileDescriptor.err));
// return createConsoleConsumer(real, predefinedWidth); // System.err might be overridden by System.setErr
// }
// Path: src/main/java/me/tongfei/progressbar/ProgressBar.java
import me.tongfei.progressbar.wrapped.*;
import static me.tongfei.progressbar.Util.createConsoleConsumer;
import java.io.*;
import java.text.DecimalFormat;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.BaseStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
package me.tongfei.progressbar;
/**
* A console-based progress bar with minimal runtime overhead.
* @author Tongfei Chen
*/
public class ProgressBar implements AutoCloseable {
private ProgressState progress;
private ProgressUpdateAction action;
private ScheduledFuture<?> scheduledTask;
/**
* Creates a progress bar with the specific taskName name and initial maximum value.
* @param task Task name
* @param initialMax Initial maximum value
*/
public ProgressBar(String task, long initialMax) {
this(task, initialMax, 1000, false, System.err, ProgressBarStyle.COLORFUL_UNICODE_BLOCK, "", 1, false, null, ChronoUnit.SECONDS, 0L, Duration.ZERO);
}
/**
* Creates a progress bar with the specific taskName name, initial maximum value,
* customized update interval (default 1000 ms), the PrintStream to be used, and output style.
* @param task Task name
* @param initialMax Initial maximum value
* @param updateIntervalMillis Update interval (default value 1000 ms)
* @param continuousUpdate Rerender every time the update interval happens regardless of progress count.
* @param style Output style (default value ProgressBarStyle.UNICODE_BLOCK)
* @param showSpeed Should the calculated speed be displayed
* @param speedFormat Speed number format
* @deprecated Use {@link ProgressBarBuilder} instead.
*/
public ProgressBar(
String task,
long initialMax,
int updateIntervalMillis,
boolean continuousUpdate,
PrintStream os,
ProgressBarStyle style,
String unitName,
long unitSize,
boolean showSpeed,
DecimalFormat speedFormat,
ChronoUnit speedUnit,
long processed,
Duration elapsed
) {
this(task, initialMax, updateIntervalMillis, continuousUpdate, processed, elapsed,
new DefaultProgressBarRenderer(style, unitName, unitSize, showSpeed, speedFormat, speedUnit),
|
createConsoleConsumer(os)
|
ctongfei/progressbar
|
src/main/java/me/tongfei/progressbar/wrapped/ProgressBarWrappedIterable.java
|
// Path: src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java
// public class ProgressBarBuilder {
//
// private String task = "";
// private long initialMax = -1;
// private int updateIntervalMillis = 1000;
// private boolean continuousUpdate = false;
// private ProgressBarStyle style = ProgressBarStyle.COLORFUL_UNICODE_BLOCK;
// private ProgressBarConsumer consumer = null;
// private String unitName = "";
// private long unitSize = 1;
// private boolean showSpeed = false;
// private DecimalFormat speedFormat;
// private ChronoUnit speedUnit = ChronoUnit.SECONDS;
// private long processed = 0;
// private Duration elapsed = Duration.ZERO;
// private int maxRenderedLength = -1;
//
// public ProgressBarBuilder() { }
//
// public ProgressBarBuilder setTaskName(String task) {
// this.task = task;
// return this;
// }
//
// boolean initialMaxIsSet() {
// return this.initialMax != -1;
// }
//
// public ProgressBarBuilder setInitialMax(long initialMax) {
// this.initialMax = initialMax;
// return this;
// }
//
// public ProgressBarBuilder setStyle(ProgressBarStyle style) {
// this.style = style;
// return this;
// }
//
// public ProgressBarBuilder setUpdateIntervalMillis(int updateIntervalMillis) {
// this.updateIntervalMillis = updateIntervalMillis;
// return this;
// }
//
// public ProgressBarBuilder continuousUpdate() {
// this.continuousUpdate = true;
// return this;
// }
//
// public ProgressBarBuilder setConsumer(ProgressBarConsumer consumer) {
// this.consumer = consumer;
// return this;
// }
//
// public ProgressBarBuilder setUnit(String unitName, long unitSize) {
// this.unitName = unitName;
// this.unitSize = unitSize;
// return this;
// }
//
// public ProgressBarBuilder setMaxRenderedLength(int maxRenderedLength) {
// this.maxRenderedLength = maxRenderedLength;
// return this;
// }
//
// public ProgressBarBuilder showSpeed() {
// return showSpeed(new DecimalFormat("#.0"));
// }
//
// public ProgressBarBuilder showSpeed(DecimalFormat speedFormat) {
// this.showSpeed = true;
// this.speedFormat = speedFormat;
// return this;
// }
//
// public ProgressBarBuilder setSpeedUnit(ChronoUnit speedUnit) {
// this.speedUnit = speedUnit;
// return this;
// }
//
// /**
// * Sets elapsedBeforeStart duration and number of processed units.
// * @param processed amount of processed units
// * @param elapsed duration of
// */
// public ProgressBarBuilder startsFrom(long processed, Duration elapsed) {
// this.processed = processed;
// this.elapsed = elapsed;
// return this;
// }
//
// public ProgressBar build() {
// return new ProgressBar(
// task,
// initialMax,
// updateIntervalMillis,
// continuousUpdate,
// processed,
// elapsed,
// new DefaultProgressBarRenderer(style, unitName, unitSize, showSpeed, speedFormat, speedUnit),
// consumer == null ? Util.createConsoleConsumer(maxRenderedLength) : consumer
// );
// }
// }
|
import me.tongfei.progressbar.ProgressBarBuilder;
import java.util.Iterator;
|
package me.tongfei.progressbar.wrapped;
/**
* Any iterable, when being iterated over, is tracked by a progress bar.
* @author Tongfei Chen
* @since 0.6.0
*/
public class ProgressBarWrappedIterable<T> implements Iterable<T> {
private Iterable<T> underlying;
|
// Path: src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java
// public class ProgressBarBuilder {
//
// private String task = "";
// private long initialMax = -1;
// private int updateIntervalMillis = 1000;
// private boolean continuousUpdate = false;
// private ProgressBarStyle style = ProgressBarStyle.COLORFUL_UNICODE_BLOCK;
// private ProgressBarConsumer consumer = null;
// private String unitName = "";
// private long unitSize = 1;
// private boolean showSpeed = false;
// private DecimalFormat speedFormat;
// private ChronoUnit speedUnit = ChronoUnit.SECONDS;
// private long processed = 0;
// private Duration elapsed = Duration.ZERO;
// private int maxRenderedLength = -1;
//
// public ProgressBarBuilder() { }
//
// public ProgressBarBuilder setTaskName(String task) {
// this.task = task;
// return this;
// }
//
// boolean initialMaxIsSet() {
// return this.initialMax != -1;
// }
//
// public ProgressBarBuilder setInitialMax(long initialMax) {
// this.initialMax = initialMax;
// return this;
// }
//
// public ProgressBarBuilder setStyle(ProgressBarStyle style) {
// this.style = style;
// return this;
// }
//
// public ProgressBarBuilder setUpdateIntervalMillis(int updateIntervalMillis) {
// this.updateIntervalMillis = updateIntervalMillis;
// return this;
// }
//
// public ProgressBarBuilder continuousUpdate() {
// this.continuousUpdate = true;
// return this;
// }
//
// public ProgressBarBuilder setConsumer(ProgressBarConsumer consumer) {
// this.consumer = consumer;
// return this;
// }
//
// public ProgressBarBuilder setUnit(String unitName, long unitSize) {
// this.unitName = unitName;
// this.unitSize = unitSize;
// return this;
// }
//
// public ProgressBarBuilder setMaxRenderedLength(int maxRenderedLength) {
// this.maxRenderedLength = maxRenderedLength;
// return this;
// }
//
// public ProgressBarBuilder showSpeed() {
// return showSpeed(new DecimalFormat("#.0"));
// }
//
// public ProgressBarBuilder showSpeed(DecimalFormat speedFormat) {
// this.showSpeed = true;
// this.speedFormat = speedFormat;
// return this;
// }
//
// public ProgressBarBuilder setSpeedUnit(ChronoUnit speedUnit) {
// this.speedUnit = speedUnit;
// return this;
// }
//
// /**
// * Sets elapsedBeforeStart duration and number of processed units.
// * @param processed amount of processed units
// * @param elapsed duration of
// */
// public ProgressBarBuilder startsFrom(long processed, Duration elapsed) {
// this.processed = processed;
// this.elapsed = elapsed;
// return this;
// }
//
// public ProgressBar build() {
// return new ProgressBar(
// task,
// initialMax,
// updateIntervalMillis,
// continuousUpdate,
// processed,
// elapsed,
// new DefaultProgressBarRenderer(style, unitName, unitSize, showSpeed, speedFormat, speedUnit),
// consumer == null ? Util.createConsoleConsumer(maxRenderedLength) : consumer
// );
// }
// }
// Path: src/main/java/me/tongfei/progressbar/wrapped/ProgressBarWrappedIterable.java
import me.tongfei.progressbar.ProgressBarBuilder;
import java.util.Iterator;
package me.tongfei.progressbar.wrapped;
/**
* Any iterable, when being iterated over, is tracked by a progress bar.
* @author Tongfei Chen
* @since 0.6.0
*/
public class ProgressBarWrappedIterable<T> implements Iterable<T> {
private Iterable<T> underlying;
|
private ProgressBarBuilder pbb;
|
ctongfei/progressbar
|
src/main/java/me/tongfei/progressbar/ConsoleProgressBarConsumer.java
|
// Path: src/main/java/me/tongfei/progressbar/TerminalUtils.java
// static final char CARRIAGE_RETURN = '\r';
|
import java.io.PrintStream;
import static me.tongfei.progressbar.TerminalUtils.CARRIAGE_RETURN;
|
package me.tongfei.progressbar;
/**
* Progress bar consumer that prints the progress bar state to console.
* By default {@link System#err} is used as {@link PrintStream}.
*
* @author Tongfei Chen
* @author Alex Peelman
*/
public class ConsoleProgressBarConsumer implements ProgressBarConsumer {
private static int consoleRightMargin = 1;
int maxRenderedLength = -1;
final PrintStream out;
public ConsoleProgressBarConsumer(PrintStream out) {
this.out = out;
}
public ConsoleProgressBarConsumer(PrintStream out, int maxRenderedLength) {
this.maxRenderedLength = maxRenderedLength;
this.out = out;
}
@Override
public int getMaxRenderedLength() {
if (maxRenderedLength <= 0)
return TerminalUtils.getTerminalWidth() - consoleRightMargin;
else return maxRenderedLength;
}
@Override
public void accept(String str) {
|
// Path: src/main/java/me/tongfei/progressbar/TerminalUtils.java
// static final char CARRIAGE_RETURN = '\r';
// Path: src/main/java/me/tongfei/progressbar/ConsoleProgressBarConsumer.java
import java.io.PrintStream;
import static me.tongfei.progressbar.TerminalUtils.CARRIAGE_RETURN;
package me.tongfei.progressbar;
/**
* Progress bar consumer that prints the progress bar state to console.
* By default {@link System#err} is used as {@link PrintStream}.
*
* @author Tongfei Chen
* @author Alex Peelman
*/
public class ConsoleProgressBarConsumer implements ProgressBarConsumer {
private static int consoleRightMargin = 1;
int maxRenderedLength = -1;
final PrintStream out;
public ConsoleProgressBarConsumer(PrintStream out) {
this.out = out;
}
public ConsoleProgressBarConsumer(PrintStream out, int maxRenderedLength) {
this.maxRenderedLength = maxRenderedLength;
this.out = out;
}
@Override
public int getMaxRenderedLength() {
if (maxRenderedLength <= 0)
return TerminalUtils.getTerminalWidth() - consoleRightMargin;
else return maxRenderedLength;
}
@Override
public void accept(String str) {
|
out.print(CARRIAGE_RETURN + StringDisplayUtils.trimDisplayLength(str, getMaxRenderedLength()));
|
anroOfCode/hijack-infinity
|
android/rpc-app/src/umich/framjack/FramJack.java
|
// Path: android/rpc-app/src/umich/framjack/ApplicationInterface.java
// public interface UpdateListener {
// public abstract void Update();
// }
|
import java.text.DecimalFormat;
import umich.framjack.ApplicationInterface.UpdateListener;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView;
|
/*
* This file is part of hijack-infinity.
*
* hijack-infinity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* hijack-infinity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
package umich.framjack;
public class FramJack extends Activity {
private ApplicationInterface _appInterface;
private TextView _tvIn1;
private TextView _tvIn2;
private TextView _tvIn3;
private TextView _tvIn4;
private TextView _tvTemp;
private TextView _tvStatus;
private Switch _swOut1;
private Switch _swOut2;
private Switch _swOut3;
private Switch _swOut4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fram_jack);
_appInterface = new ApplicationInterface();
bindControls();
_appInterface.registerOnUpdateListener(_listener);
attachCheckChangeListeners();
}
|
// Path: android/rpc-app/src/umich/framjack/ApplicationInterface.java
// public interface UpdateListener {
// public abstract void Update();
// }
// Path: android/rpc-app/src/umich/framjack/FramJack.java
import java.text.DecimalFormat;
import umich.framjack.ApplicationInterface.UpdateListener;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView;
/*
* This file is part of hijack-infinity.
*
* hijack-infinity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* hijack-infinity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with hijack-infinity. If not, see <http://www.gnu.org/licenses/>.
*/
package umich.framjack;
public class FramJack extends Activity {
private ApplicationInterface _appInterface;
private TextView _tvIn1;
private TextView _tvIn2;
private TextView _tvIn3;
private TextView _tvIn4;
private TextView _tvTemp;
private TextView _tvStatus;
private Switch _swOut1;
private Switch _swOut2;
private Switch _swOut3;
private Switch _swOut4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fram_jack);
_appInterface = new ApplicationInterface();
bindControls();
_appInterface.registerOnUpdateListener(_listener);
attachCheckChangeListeners();
}
|
private UpdateListener _listener = new UpdateListener() {
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemBoneShard.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemBoneShard extends Item implements IBBName
{
public ItemBoneShard()
{
super();
setUnlocalizedName("boneShard");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemBoneShard.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
package net.einsteinsci.betterbeginnings.items;
public class ItemBoneShard extends Item implements IBBName
{
public ItemBoneShard()
{
super();
setUnlocalizedName("boneShard");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemPan.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemPan extends Item implements ICampfireUtensil
{
public ItemPan()
{
super();
setUnlocalizedName(getName());
setMaxDamage(250);
setMaxStackSize(1);
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemPan.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
package net.einsteinsci.betterbeginnings.items;
public class ItemPan extends Item implements ICampfireUtensil
{
public ItemPan()
{
super();
setUnlocalizedName(getName());
setMaxDamage(250);
setMaxStackSize(1);
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemBBCloth.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemBBCloth extends Item implements IBBName
{
public ItemBBCloth()
{
super();
setUnlocalizedName("cloth");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemBBCloth.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
package net.einsteinsci.betterbeginnings.items;
public class ItemBBCloth extends Item implements IBBName
{
public ItemBBCloth()
{
super();
setUnlocalizedName("cloth");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/AdvancedCraftingHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/inventory/InventoryWorkbenchAdditionalMaterials.java
// public class InventoryWorkbenchAdditionalMaterials implements IInventory
// {
// private ItemStack[] stackList;
//
// private Container container;
//
// public InventoryWorkbenchAdditionalMaterials(Container container_, int size)
// {
// stackList = new ItemStack[size];
// container = container_;
// }
//
// @Override
// public int getSizeInventory()
// {
// return stackList.length;
// }
//
// @Override
// public ItemStack getStackInSlot(int slot)
// {
// if (getSizeInventory() <= slot)
// {
// return null;
// }
// else
// {
// return stackList[slot];
// }
// }
//
// @Override
// public ItemStack decrStackSize(int slot, int amount)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack;
//
// if (stackList[slot].stackSize <= amount)
// {
// itemstack = stackList[slot];
// stackList[slot] = null;
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// else
// {
// itemstack = stackList[slot].splitStack(amount);
//
// if (stackList[slot].stackSize == 0)
// {
// stackList[slot] = null;
// }
//
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public ItemStack getStackInSlotOnClosing(int slot)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack = stackList[slot];
// stackList[slot] = null;
// return itemstack;
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public void setInventorySlotContents(int slot, ItemStack stack)
// {
// stackList[slot] = stack;
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public String getCommandSenderName()
// {
// return "container.workbenchmaterials";
// }
//
// @Override
// public boolean hasCustomName()
// {
// return false;
// }
//
// @Override
// public IChatComponent getDisplayName()
// {
// return new ChatComponentText(getCommandSenderName());
// }
//
// @Override
// public int getInventoryStackLimit()
// {
// return 64;
// }
//
// @Override
// public void markDirty()
// {
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public boolean isUseableByPlayer(EntityPlayer player)
// {
// return true;
// }
//
// @Override
// public void openInventory(EntityPlayer player)
// { }
//
// @Override
// public void closeInventory(EntityPlayer player)
// { }
//
// @Override
// public boolean isItemValidForSlot(int slot, ItemStack stack)
// {
// return true;
// }
//
// @Override
// public int getField(int id)
// {
// return 0;
// }
//
// @Override
// public void setField(int id, int value)
// { }
//
// @Override
// public int getFieldCount()
// {
// return 0;
// }
//
// @Override
// public void clear()
// {
// for (int i = 0; i < stackList.length; i++)
// {
// stackList[i] = null;
// }
// }
// }
|
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
|
if (hashmap.containsKey(Character.valueOf(iterChar)))
{
neededItems[j] = ((OreRecipeElement)hashmap.get(Character.valueOf(iterChar))).copy();
}
else
{
neededItems[j] = null;
}
}
AdvancedRecipe advancedrecipes = new AdvancedRecipe(width, height, neededItems, result, addedMats, hide);
recipes.add(advancedrecipes);
return advancedrecipes;
}
public static AdvancedCraftingHandler crafting()
{
return CRAFTING;
}
public static AdvancedRecipe advancedRecipeByResultAndContents(ItemStack result,
IInventory craftMatrix, IInventory additionalMaterials, World world)
{
for (Object obj : crafting().recipes)
{
if (obj instanceof AdvancedRecipe)
{
AdvancedRecipe recipe = (AdvancedRecipe)obj;
if (recipe.matches((InventoryCrafting)craftMatrix,
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/inventory/InventoryWorkbenchAdditionalMaterials.java
// public class InventoryWorkbenchAdditionalMaterials implements IInventory
// {
// private ItemStack[] stackList;
//
// private Container container;
//
// public InventoryWorkbenchAdditionalMaterials(Container container_, int size)
// {
// stackList = new ItemStack[size];
// container = container_;
// }
//
// @Override
// public int getSizeInventory()
// {
// return stackList.length;
// }
//
// @Override
// public ItemStack getStackInSlot(int slot)
// {
// if (getSizeInventory() <= slot)
// {
// return null;
// }
// else
// {
// return stackList[slot];
// }
// }
//
// @Override
// public ItemStack decrStackSize(int slot, int amount)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack;
//
// if (stackList[slot].stackSize <= amount)
// {
// itemstack = stackList[slot];
// stackList[slot] = null;
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// else
// {
// itemstack = stackList[slot].splitStack(amount);
//
// if (stackList[slot].stackSize == 0)
// {
// stackList[slot] = null;
// }
//
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public ItemStack getStackInSlotOnClosing(int slot)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack = stackList[slot];
// stackList[slot] = null;
// return itemstack;
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public void setInventorySlotContents(int slot, ItemStack stack)
// {
// stackList[slot] = stack;
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public String getCommandSenderName()
// {
// return "container.workbenchmaterials";
// }
//
// @Override
// public boolean hasCustomName()
// {
// return false;
// }
//
// @Override
// public IChatComponent getDisplayName()
// {
// return new ChatComponentText(getCommandSenderName());
// }
//
// @Override
// public int getInventoryStackLimit()
// {
// return 64;
// }
//
// @Override
// public void markDirty()
// {
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public boolean isUseableByPlayer(EntityPlayer player)
// {
// return true;
// }
//
// @Override
// public void openInventory(EntityPlayer player)
// { }
//
// @Override
// public void closeInventory(EntityPlayer player)
// { }
//
// @Override
// public boolean isItemValidForSlot(int slot, ItemStack stack)
// {
// return true;
// }
//
// @Override
// public int getField(int id)
// {
// return 0;
// }
//
// @Override
// public void setField(int id, int value)
// { }
//
// @Override
// public int getFieldCount()
// {
// return 0;
// }
//
// @Override
// public void clear()
// {
// for (int i = 0; i < stackList.length; i++)
// {
// stackList[i] = null;
// }
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/AdvancedCraftingHandler.java
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
if (hashmap.containsKey(Character.valueOf(iterChar)))
{
neededItems[j] = ((OreRecipeElement)hashmap.get(Character.valueOf(iterChar))).copy();
}
else
{
neededItems[j] = null;
}
}
AdvancedRecipe advancedrecipes = new AdvancedRecipe(width, height, neededItems, result, addedMats, hide);
recipes.add(advancedrecipes);
return advancedrecipes;
}
public static AdvancedCraftingHandler crafting()
{
return CRAFTING;
}
public static AdvancedRecipe advancedRecipeByResultAndContents(ItemStack result,
IInventory craftMatrix, IInventory additionalMaterials, World world)
{
for (Object obj : crafting().recipes)
{
if (obj instanceof AdvancedRecipe)
{
AdvancedRecipe recipe = (AdvancedRecipe)obj;
if (recipe.matches((InventoryCrafting)craftMatrix,
|
(InventoryWorkbenchAdditionalMaterials)additionalMaterials, world))
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/nei/NEIBrickOvenRecipeHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import codechicken.nei.ItemList;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.gui.GuiBrickOven;
import net.einsteinsci.betterbeginnings.register.recipe.*;
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
|
if (found)
{
arecipes.add(new BrickOvenCachedRecipe(ibr));
}
}
}
public static ArrayList<FuelPair> afuels;
@Override
public TemplateRecipeHandler newInstance()
{
if (afuels == null || afuels.isEmpty())
{
findFuels();
}
return super.newInstance();
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiBrickOven.class;
}
@Override
public String getGuiTexture()
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/nei/NEIBrickOvenRecipeHandler.java
import codechicken.nei.ItemList;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.gui.GuiBrickOven;
import net.einsteinsci.betterbeginnings.register.recipe.*;
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
if (found)
{
arecipes.add(new BrickOvenCachedRecipe(ibr));
}
}
}
public static ArrayList<FuelPair> afuels;
@Override
public TemplateRecipeHandler newInstance()
{
if (afuels == null || afuels.isEmpty())
{
findFuels();
}
return super.newInstance();
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiBrickOven.class;
}
@Override
public String getGuiTexture()
{
|
return ModMain.MODID + ":textures/gui/container/brickOven.png";
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
|
package net.einsteinsci.betterbeginnings.config.json;
public class BoosterConfig implements IJsonConfig
{
public static final BoosterConfig INSTANCE = new BoosterConfig();
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package net.einsteinsci.betterbeginnings.config.json;
public class BoosterConfig implements IJsonConfig
{
public static final BoosterConfig INSTANCE = new BoosterConfig();
|
private static JsonBoosterHandler initialAssociations = new JsonBoosterHandler();
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
|
package net.einsteinsci.betterbeginnings.config.json;
public class BoosterConfig implements IJsonConfig
{
public static final BoosterConfig INSTANCE = new BoosterConfig();
private static JsonBoosterHandler initialAssociations = new JsonBoosterHandler();
private JsonBoosterHandler mainBoosters = new JsonBoosterHandler();
private JsonBoosterHandler customBoosters = new JsonBoosterHandler();
private List<JsonBoosterHandler> includes = new ArrayList<>();
public static void registerBooster(ItemStack booster, float amount)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
package net.einsteinsci.betterbeginnings.config.json;
public class BoosterConfig implements IJsonConfig
{
public static final BoosterConfig INSTANCE = new BoosterConfig();
private static JsonBoosterHandler initialAssociations = new JsonBoosterHandler();
private JsonBoosterHandler mainBoosters = new JsonBoosterHandler();
private JsonBoosterHandler customBoosters = new JsonBoosterHandler();
private List<JsonBoosterHandler> includes = new ArrayList<>();
public static void registerBooster(ItemStack booster, float amount)
{
|
initialAssociations.getBoosters().add(new JsonBooster(booster, amount));
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
|
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
mainBoosters = BBJsonLoader.deserializeObject(mainJson, JsonBoosterHandler.class);
for (JsonBooster j : mainBoosters.getBoosters())
{
j.register();
}
customBoosters = BBJsonLoader.deserializeObject(customJson, JsonBoosterHandler.class);
for (JsonBooster j : customBoosters.getBoosters())
{
j.register();
}
}
@Override
public void loadIncludedConfig(FMLInitializationEvent e, List<String> includedJsons)
{
for (String json : includedJsons)
{
JsonBoosterHandler handler = BBJsonLoader.deserializeObject(json, JsonBoosterHandler.class);
if (handler == null)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBooster.java
// public class JsonBooster
// {
// private JsonLoadedItem boosterItem;
// private float boostAmount;
//
// public JsonBooster(ItemStack stack, float boost)
// {
// boosterItem = new JsonLoadedItem(stack);
// boostAmount = boost;
// }
// public JsonBooster(Item item, float boost)
// {
// this(new ItemStack(item), boost);
// }
// public JsonBooster(Block block, float boost)
// {
// this(new ItemStack(block), boost);
// }
//
// public void register()
// {
// if (boosterItem.isOreDictionary())
// {
// for (ItemStack stack : OreDictionary.getOres(boosterItem.getItemName()))
// {
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
// else
// {
// ItemStack stack = boosterItem.getFirstItemStackOrNull();
// if (stack != null)
// {
// TileEntitySmelterBase.registerBooster(stack, boostAmount);
// }
// }
// }
//
// public JsonLoadedItem getBoosterItem()
// {
// return boosterItem;
// }
//
// public float getBoostAmount()
// {
// return boostAmount;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonBoosterHandler.java
// public class JsonBoosterHandler
// {
// private List<JsonBooster> boosters = new ArrayList<>();
//
// private List<String> includes = new ArrayList<>();
// private List<String> modDependencies = new ArrayList<>();
//
// public List<JsonBooster> getBoosters()
// {
// return boosters;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/BoosterConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBooster;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonBoosterHandler;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
mainBoosters = BBJsonLoader.deserializeObject(mainJson, JsonBoosterHandler.class);
for (JsonBooster j : mainBoosters.getBoosters())
{
j.register();
}
customBoosters = BBJsonLoader.deserializeObject(customJson, JsonBoosterHandler.class);
for (JsonBooster j : customBoosters.getBoosters())
{
j.register();
}
}
@Override
public void loadIncludedConfig(FMLInitializationEvent e, List<String> includedJsons)
{
for (String json : includedJsons)
{
JsonBoosterHandler handler = BBJsonLoader.deserializeObject(json, JsonBoosterHandler.class);
if (handler == null)
{
|
LogUtil.log(Level.ERROR, "Could not deserialize included json.");
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemMarshmallowCooked.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemFood;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemMarshmallowCooked extends ItemFood implements IBBName
{
public ItemMarshmallowCooked()
{
super(5, 6.0f, false);
setUnlocalizedName("marshmallowCooked");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemMarshmallowCooked.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemFood;
package net.einsteinsci.betterbeginnings.items;
public class ItemMarshmallowCooked extends ItemFood implements IBBName
{
public ItemMarshmallowCooked()
{
super(5, 6.0f, false);
setUnlocalizedName("marshmallowCooked");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/SmelterRecipeHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
|
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import java.util.Map.Entry;
|
do
{
if (!iterator.hasNext())
{
return 0.0f;
}
entry = (Entry)iterator.next();
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
if (stack.getItem().getSmeltingExperience(stack) != -1)
{
return stack.getItem().getSmeltingExperience(stack);
}
return (Float)entry.getValue();
}
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
{
return stack2.getItem() == stack.getItem() &&
(stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
.getItemDamage());
}
public boolean existsRecipeFor(ItemStack stack)
{
for (SmelterRecipe recipe : recipes)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/SmelterRecipeHandler.java
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import java.util.Map.Entry;
do
{
if (!iterator.hasNext())
{
return 0.0f;
}
entry = (Entry)iterator.next();
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
if (stack.getItem().getSmeltingExperience(stack) != -1)
{
return stack.getItem().getSmeltingExperience(stack);
}
return (Float)entry.getValue();
}
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
{
return stack2.getItem() == stack.getItem() &&
(stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
.getItemDamage());
}
public boolean existsRecipeFor(ItemStack stack)
{
for (SmelterRecipe recipe : recipes)
{
|
if (Util.areItemStacksEqualIgnoreSize(recipe.getOutput(), stack))
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemIronNugget.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemIronNugget extends Item implements IBBName
{
public ItemIronNugget()
{
super();
setUnlocalizedName("ironNugget");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemIronNugget.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
package net.einsteinsci.betterbeginnings.items;
public class ItemIronNugget extends Item implements IBBName
{
public ItemIronNugget()
{
super();
setUnlocalizedName("ironNugget");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/AdvancedRecipe.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/inventory/InventoryWorkbenchAdditionalMaterials.java
// public class InventoryWorkbenchAdditionalMaterials implements IInventory
// {
// private ItemStack[] stackList;
//
// private Container container;
//
// public InventoryWorkbenchAdditionalMaterials(Container container_, int size)
// {
// stackList = new ItemStack[size];
// container = container_;
// }
//
// @Override
// public int getSizeInventory()
// {
// return stackList.length;
// }
//
// @Override
// public ItemStack getStackInSlot(int slot)
// {
// if (getSizeInventory() <= slot)
// {
// return null;
// }
// else
// {
// return stackList[slot];
// }
// }
//
// @Override
// public ItemStack decrStackSize(int slot, int amount)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack;
//
// if (stackList[slot].stackSize <= amount)
// {
// itemstack = stackList[slot];
// stackList[slot] = null;
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// else
// {
// itemstack = stackList[slot].splitStack(amount);
//
// if (stackList[slot].stackSize == 0)
// {
// stackList[slot] = null;
// }
//
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public ItemStack getStackInSlotOnClosing(int slot)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack = stackList[slot];
// stackList[slot] = null;
// return itemstack;
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public void setInventorySlotContents(int slot, ItemStack stack)
// {
// stackList[slot] = stack;
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public String getCommandSenderName()
// {
// return "container.workbenchmaterials";
// }
//
// @Override
// public boolean hasCustomName()
// {
// return false;
// }
//
// @Override
// public IChatComponent getDisplayName()
// {
// return new ChatComponentText(getCommandSenderName());
// }
//
// @Override
// public int getInventoryStackLimit()
// {
// return 64;
// }
//
// @Override
// public void markDirty()
// {
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public boolean isUseableByPlayer(EntityPlayer player)
// {
// return true;
// }
//
// @Override
// public void openInventory(EntityPlayer player)
// { }
//
// @Override
// public void closeInventory(EntityPlayer player)
// { }
//
// @Override
// public boolean isItemValidForSlot(int slot, ItemStack stack)
// {
// return true;
// }
//
// @Override
// public int getField(int id)
// {
// return 0;
// }
//
// @Override
// public void setField(int id, int value)
// { }
//
// @Override
// public int getFieldCount()
// {
// return 0;
// }
//
// @Override
// public void clear()
// {
// for (int i = 0; i < stackList.length; i++)
// {
// stackList[i] = null;
// }
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import org.apache.logging.log4j.Level;
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
|
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
{
if (mirror)
{
neededCraftingStack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
}
else
{
neededCraftingStack = recipeItems[i1 + j1 * recipeWidth];
}
}
ItemStack craftingStackInQuestion = crafting.getStackInRowAndColumn(k, l);
if (craftingStackInQuestion != null && neededCraftingStack != null)
{
if (!neededCraftingStack.matches(craftingStackInQuestion))
{
return false;
}
}
else if ((craftingStackInQuestion == null) ^ (neededCraftingStack == null))
{
return false;
}
}
}
if(addedMaterials.length > materials.getSizeInventory())
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/inventory/InventoryWorkbenchAdditionalMaterials.java
// public class InventoryWorkbenchAdditionalMaterials implements IInventory
// {
// private ItemStack[] stackList;
//
// private Container container;
//
// public InventoryWorkbenchAdditionalMaterials(Container container_, int size)
// {
// stackList = new ItemStack[size];
// container = container_;
// }
//
// @Override
// public int getSizeInventory()
// {
// return stackList.length;
// }
//
// @Override
// public ItemStack getStackInSlot(int slot)
// {
// if (getSizeInventory() <= slot)
// {
// return null;
// }
// else
// {
// return stackList[slot];
// }
// }
//
// @Override
// public ItemStack decrStackSize(int slot, int amount)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack;
//
// if (stackList[slot].stackSize <= amount)
// {
// itemstack = stackList[slot];
// stackList[slot] = null;
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// else
// {
// itemstack = stackList[slot].splitStack(amount);
//
// if (stackList[slot].stackSize == 0)
// {
// stackList[slot] = null;
// }
//
// container.onCraftMatrixChanged(this);
// return itemstack;
// }
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public ItemStack getStackInSlotOnClosing(int slot)
// {
// if (stackList[slot] != null)
// {
// ItemStack itemstack = stackList[slot];
// stackList[slot] = null;
// return itemstack;
// }
// else
// {
// return null;
// }
// }
//
// @Override
// public void setInventorySlotContents(int slot, ItemStack stack)
// {
// stackList[slot] = stack;
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public String getCommandSenderName()
// {
// return "container.workbenchmaterials";
// }
//
// @Override
// public boolean hasCustomName()
// {
// return false;
// }
//
// @Override
// public IChatComponent getDisplayName()
// {
// return new ChatComponentText(getCommandSenderName());
// }
//
// @Override
// public int getInventoryStackLimit()
// {
// return 64;
// }
//
// @Override
// public void markDirty()
// {
// container.onCraftMatrixChanged(this);
// }
//
// @Override
// public boolean isUseableByPlayer(EntityPlayer player)
// {
// return true;
// }
//
// @Override
// public void openInventory(EntityPlayer player)
// { }
//
// @Override
// public void closeInventory(EntityPlayer player)
// { }
//
// @Override
// public boolean isItemValidForSlot(int slot, ItemStack stack)
// {
// return true;
// }
//
// @Override
// public int getField(int id)
// {
// return 0;
// }
//
// @Override
// public void setField(int id, int value)
// { }
//
// @Override
// public int getFieldCount()
// {
// return 0;
// }
//
// @Override
// public void clear()
// {
// for (int i = 0; i < stackList.length; i++)
// {
// stackList[i] = null;
// }
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/AdvancedRecipe.java
import org.apache.logging.log4j.Level;
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
{
if (mirror)
{
neededCraftingStack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
}
else
{
neededCraftingStack = recipeItems[i1 + j1 * recipeWidth];
}
}
ItemStack craftingStackInQuestion = crafting.getStackInRowAndColumn(k, l);
if (craftingStackInQuestion != null && neededCraftingStack != null)
{
if (!neededCraftingStack.matches(craftingStackInQuestion))
{
return false;
}
}
else if ((craftingStackInQuestion == null) ^ (neededCraftingStack == null))
{
return false;
}
}
}
if(addedMaterials.length > materials.getSizeInventory())
{
|
LogUtil.log(Level.ERROR, "Recipe for " + this.recipeOutput.getDisplayName() + " has too many catalysts required.");
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/RegisterTileEntities.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.tileentity.*;
import net.minecraftforge.fml.common.registry.GameRegistry;
|
package net.einsteinsci.betterbeginnings.register;
public class RegisterTileEntities
{
public static void register()
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/RegisterTileEntities.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.tileentity.*;
import net.minecraftforge.fml.common.registry.GameRegistry;
package net.einsteinsci.betterbeginnings.register;
public class RegisterTileEntities
{
public static void register()
{
|
GameRegistry.registerTileEntity(TileEntityKiln.class, ModMain.MODID + ":TileEntityKiln");
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/client/RenderThrownKnife.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/entity/projectile/EntityThrownKnife.java
// public class EntityThrownKnife extends EntityThrowable implements IEntityAdditionalSpawnData
// {
// private static final String TAG_THROWN_KNIFE = "ThrownKnife";
//
// private ItemStack knife;
// private float baseDamage;
// private float force;
// private boolean inTerrain;
// private BlockPos stuckPos = new BlockPos(-1, -1, -1);
//
// public EntityThrownKnife(World worldIn)
// {
// super(worldIn);
// }
//
// public EntityThrownKnife(World world, EntityLivingBase thrower, ItemStack knife)
// {
// super(world, thrower);
// this.knife = knife;
// this.baseDamage = ((ItemTool)knife.getItem()).getToolMaterial().getDamageVsEntity() + ItemKnife.DAMAGE;
// }
//
// @Override
// protected void onImpact(MovingObjectPosition mop)
// {
// switch(mop.typeOfHit)
// {
// case BLOCK:
// if (!inTerrain)
// {
// doBlockHitEffects(worldObj, mop);
// }
// BlockPos pos = mop.getBlockPos();
// IBlockState state = worldObj.getBlockState(pos);
// if(state.getBlock().getCollisionBoundingBox(worldObj, pos, state) != null)
// {
// this.inTerrain = true;
// this.stuckPos = pos;
// this.setVelocity(0.0F, 0.0F, 0.0F);
// }
// break;
// case ENTITY:
// if(mop.entityHit instanceof EntityLivingBase)
// {
// EntityLivingBase entityLiving = (EntityLivingBase) mop.entityHit;
// if(!worldObj.isRemote && !knife.attemptDamageItem(2, rand))
// {
// entityLiving.attackEntityFrom(DamageSource.causeThrownDamage(mop.entityHit, this.getThrower()), baseDamage * force);
// entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), (int) (100 * force), 2, false, false));
// }
// }
// break;
// default:
// break;
// }
// }
//
// @Override
// public void onCollideWithPlayer(EntityPlayer playerIn)
// {
// this.knife.stackSize = 1;
// if(inTerrain && playerIn.inventory.addItemStackToInventory(this.knife))
// {
// this.setDead();
// }
// }
//
// @Override
// public void onUpdate()
// {
// if(worldObj.getBlockState(this.stuckPos).getBlock().isAir(worldObj, stuckPos))
// {
// this.inTerrain = false;
// }
// if(!inTerrain)
// {
// super.onUpdate();
// }
// }
//
// private void doBlockHitEffects(World worldObj, MovingObjectPosition mop)
// {
// IBlockState state = this.worldObj.getBlockState(mop.getBlockPos());
// for(int p = 0; p < 8; p ++)
// {
// worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F, Block.getStateId(state));
// }
// worldObj.playSoundAtEntity(this, state.getBlock().stepSound.getStepSound(), 0.8F, 0.9F);
// }
//
// @Override
// public void readEntityFromNBT(NBTTagCompound tagCompound)
// {
// super.readEntityFromNBT(tagCompound);
// knife = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(TAG_THROWN_KNIFE));
// }
//
// @Override
// public void writeEntityToNBT(NBTTagCompound tagCompound)
// {
// super.writeEntityToNBT(tagCompound);
// if(knife != null)
// {
// NBTTagCompound thrownKnife = knife.writeToNBT(new NBTTagCompound());
// tagCompound.setTag(TAG_THROWN_KNIFE, thrownKnife);
// }
// }
//
// public ItemStack getKnife()
// {
// return knife;
// }
//
// public EntityThrownKnife setForce(float force)
// {
// this.force = force;
// return this;
// }
//
// @Override
// public void writeSpawnData(ByteBuf additionalData)
// {
// ByteBufUtils.writeItemStack(additionalData, knife);
// additionalData.writeFloat(baseDamage);
// additionalData.writeFloat(force);
// }
//
// @Override
// public void readSpawnData(ByteBuf additionalData)
// {
// knife = ByteBufUtils.readItemStack(additionalData);
// baseDamage = additionalData.readFloat();
// force = additionalData.readFloat();
// }
// }
|
import net.einsteinsci.betterbeginnings.entity.projectile.EntityThrownKnife;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
|
package net.einsteinsci.betterbeginnings.client;
public class RenderThrownKnife extends RenderSnowball
{
public RenderThrownKnife(Minecraft minecraft)
{
super(minecraft.getRenderManager(), Items.stick, minecraft.getRenderItem());
}
@Override
public ItemStack func_177082_d(Entity entityIn)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/entity/projectile/EntityThrownKnife.java
// public class EntityThrownKnife extends EntityThrowable implements IEntityAdditionalSpawnData
// {
// private static final String TAG_THROWN_KNIFE = "ThrownKnife";
//
// private ItemStack knife;
// private float baseDamage;
// private float force;
// private boolean inTerrain;
// private BlockPos stuckPos = new BlockPos(-1, -1, -1);
//
// public EntityThrownKnife(World worldIn)
// {
// super(worldIn);
// }
//
// public EntityThrownKnife(World world, EntityLivingBase thrower, ItemStack knife)
// {
// super(world, thrower);
// this.knife = knife;
// this.baseDamage = ((ItemTool)knife.getItem()).getToolMaterial().getDamageVsEntity() + ItemKnife.DAMAGE;
// }
//
// @Override
// protected void onImpact(MovingObjectPosition mop)
// {
// switch(mop.typeOfHit)
// {
// case BLOCK:
// if (!inTerrain)
// {
// doBlockHitEffects(worldObj, mop);
// }
// BlockPos pos = mop.getBlockPos();
// IBlockState state = worldObj.getBlockState(pos);
// if(state.getBlock().getCollisionBoundingBox(worldObj, pos, state) != null)
// {
// this.inTerrain = true;
// this.stuckPos = pos;
// this.setVelocity(0.0F, 0.0F, 0.0F);
// }
// break;
// case ENTITY:
// if(mop.entityHit instanceof EntityLivingBase)
// {
// EntityLivingBase entityLiving = (EntityLivingBase) mop.entityHit;
// if(!worldObj.isRemote && !knife.attemptDamageItem(2, rand))
// {
// entityLiving.attackEntityFrom(DamageSource.causeThrownDamage(mop.entityHit, this.getThrower()), baseDamage * force);
// entityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), (int) (100 * force), 2, false, false));
// }
// }
// break;
// default:
// break;
// }
// }
//
// @Override
// public void onCollideWithPlayer(EntityPlayer playerIn)
// {
// this.knife.stackSize = 1;
// if(inTerrain && playerIn.inventory.addItemStackToInventory(this.knife))
// {
// this.setDead();
// }
// }
//
// @Override
// public void onUpdate()
// {
// if(worldObj.getBlockState(this.stuckPos).getBlock().isAir(worldObj, stuckPos))
// {
// this.inTerrain = false;
// }
// if(!inTerrain)
// {
// super.onUpdate();
// }
// }
//
// private void doBlockHitEffects(World worldObj, MovingObjectPosition mop)
// {
// IBlockState state = this.worldObj.getBlockState(mop.getBlockPos());
// for(int p = 0; p < 8; p ++)
// {
// worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F, Block.getStateId(state));
// }
// worldObj.playSoundAtEntity(this, state.getBlock().stepSound.getStepSound(), 0.8F, 0.9F);
// }
//
// @Override
// public void readEntityFromNBT(NBTTagCompound tagCompound)
// {
// super.readEntityFromNBT(tagCompound);
// knife = ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag(TAG_THROWN_KNIFE));
// }
//
// @Override
// public void writeEntityToNBT(NBTTagCompound tagCompound)
// {
// super.writeEntityToNBT(tagCompound);
// if(knife != null)
// {
// NBTTagCompound thrownKnife = knife.writeToNBT(new NBTTagCompound());
// tagCompound.setTag(TAG_THROWN_KNIFE, thrownKnife);
// }
// }
//
// public ItemStack getKnife()
// {
// return knife;
// }
//
// public EntityThrownKnife setForce(float force)
// {
// this.force = force;
// return this;
// }
//
// @Override
// public void writeSpawnData(ByteBuf additionalData)
// {
// ByteBufUtils.writeItemStack(additionalData, knife);
// additionalData.writeFloat(baseDamage);
// additionalData.writeFloat(force);
// }
//
// @Override
// public void readSpawnData(ByteBuf additionalData)
// {
// knife = ByteBufUtils.readItemStack(additionalData);
// baseDamage = additionalData.readFloat();
// force = additionalData.readFloat();
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/client/RenderThrownKnife.java
import net.einsteinsci.betterbeginnings.entity.projectile.EntityThrownKnife;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
package net.einsteinsci.betterbeginnings.client;
public class RenderThrownKnife extends RenderSnowball
{
public RenderThrownKnife(Minecraft minecraft)
{
super(minecraft.getRenderManager(), Items.stick, minecraft.getRenderItem());
}
@Override
public ItemStack func_177082_d(Entity entityIn)
{
|
return ((EntityThrownKnife) entityIn).getKnife();
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemSilk.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemSilk extends Item implements IBBName
{
public ItemSilk()
{
super();
setUnlocalizedName("silk");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemSilk.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.Item;
package net.einsteinsci.betterbeginnings.items;
public class ItemSilk extends Item implements IBBName
{
public ItemSilk()
{
super();
setUnlocalizedName("silk");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/KilnRecipeHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
|
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import java.util.Map.Entry;
|
entry = iterator.next();
} while (!canBeSmelted(stack, entry.getKey()));
return entry.getValue();
}
public static Map getSmeltingList()
{
return instance().smeltingList;
}
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
{
return stack2.getItem() == stack.getItem()
&& (stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
.getItemDamage());
}
public boolean existsRecipeFrom(ItemStack input)
{
for (Object obj : getSmeltingList().entrySet())
{
if (!(obj instanceof Map.Entry))
{
continue; // No idea if this works.
}
Map.Entry<ItemStack, ItemStack> kvp = (Map.Entry<ItemStack, ItemStack>)obj;
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/KilnRecipeHandler.java
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.*;
import java.util.Map.Entry;
entry = iterator.next();
} while (!canBeSmelted(stack, entry.getKey()));
return entry.getValue();
}
public static Map getSmeltingList()
{
return instance().smeltingList;
}
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
{
return stack2.getItem() == stack.getItem()
&& (stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
.getItemDamage());
}
public boolean existsRecipeFrom(ItemStack input)
{
for (Object obj : getSmeltingList().entrySet())
{
if (!(obj instanceof Map.Entry))
{
continue; // No idea if this works.
}
Map.Entry<ItemStack, ItemStack> kvp = (Map.Entry<ItemStack, ItemStack>)obj;
|
if (Util.areItemStacksEqualIgnoreSize(input, kvp.getKey()))
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/gui/GuiObsidianKiln.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/tileentity/TileEntityObsidianKiln.java
// public class TileEntityObsidianKiln extends TileEntityKilnBase
// {
// public TileEntityObsidianKiln()
// {
// super();
// processTime = 250;
// }
//
// @Override
// public void readFromNBT(NBTTagCompound tagCompound)
// {
// super.readFromNBT(tagCompound);
// currentItemBurnLength = getItemBurnTime(specialFurnaceStacks[SLOT_FUEL]);
// }
//
// @Override
// public int getItemBurnTime(ItemStack itemStack)
// {
// if (itemStack == null)
// {
// return 0;
// }
// else
// {
// Item item = itemStack.getItem();
//
// // Blaze Rods and Lava are valid fuel sources for an obsidian kiln.
// if (item == Items.blaze_rod)
// {
// return 1600;
// }
// if (item == Items.lava_bucket)
// {
// return 80000;
// }
//
// // All fuels from the Kiln apply here too.
// return super.getItemBurnTime(itemStack);
// }
// }
//
// @Override
// public String getCommandSenderName()
// {
// return hasCustomName() ? customName : "container.obsidianKiln";
// }
//
// @Override
// public void updateBlockState()
// {
// BlockObsidianKiln.updateBlockState(burnTime > 0, worldObj, pos);
// }
//
// @Override
// public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
// {
// return new ContainerObsidianKiln(playerInventory, this);
// }
//
// @Override
// public String getGuiID()
// {
// return ModMain.MODID + ":obsidianKiln";
// }
// }
|
import net.einsteinsci.betterbeginnings.inventory.ContainerObsidianKiln;
import net.einsteinsci.betterbeginnings.tileentity.TileEntityObsidianKiln;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
|
package net.einsteinsci.betterbeginnings.gui;
public class GuiObsidianKiln extends GuiContainer
{
private static final ResourceLocation kilnGuiTextures = new ResourceLocation(
"minecraft:textures/gui/container/furnace.png");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/tileentity/TileEntityObsidianKiln.java
// public class TileEntityObsidianKiln extends TileEntityKilnBase
// {
// public TileEntityObsidianKiln()
// {
// super();
// processTime = 250;
// }
//
// @Override
// public void readFromNBT(NBTTagCompound tagCompound)
// {
// super.readFromNBT(tagCompound);
// currentItemBurnLength = getItemBurnTime(specialFurnaceStacks[SLOT_FUEL]);
// }
//
// @Override
// public int getItemBurnTime(ItemStack itemStack)
// {
// if (itemStack == null)
// {
// return 0;
// }
// else
// {
// Item item = itemStack.getItem();
//
// // Blaze Rods and Lava are valid fuel sources for an obsidian kiln.
// if (item == Items.blaze_rod)
// {
// return 1600;
// }
// if (item == Items.lava_bucket)
// {
// return 80000;
// }
//
// // All fuels from the Kiln apply here too.
// return super.getItemBurnTime(itemStack);
// }
// }
//
// @Override
// public String getCommandSenderName()
// {
// return hasCustomName() ? customName : "container.obsidianKiln";
// }
//
// @Override
// public void updateBlockState()
// {
// BlockObsidianKiln.updateBlockState(burnTime > 0, worldObj, pos);
// }
//
// @Override
// public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
// {
// return new ContainerObsidianKiln(playerInventory, this);
// }
//
// @Override
// public String getGuiID()
// {
// return ModMain.MODID + ":obsidianKiln";
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/gui/GuiObsidianKiln.java
import net.einsteinsci.betterbeginnings.inventory.ContainerObsidianKiln;
import net.einsteinsci.betterbeginnings.tileentity.TileEntityObsidianKiln;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
package net.einsteinsci.betterbeginnings.gui;
public class GuiObsidianKiln extends GuiContainer
{
private static final ResourceLocation kilnGuiTextures = new ResourceLocation(
"minecraft:textures/gui/container/furnace.png");
|
private TileEntityObsidianKiln tileKiln;
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/RegisterItems.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemBBCloth.java
// public class ItemBBCloth extends Item implements IBBName
// {
// public ItemBBCloth()
// {
// super();
//
// setUnlocalizedName("cloth");
//
// setCreativeTab(ModMain.tabBetterBeginnings);
// }
//
// @Override
// public String getName()
// {
// return "cloth";
// }
// }
|
import net.einsteinsci.betterbeginnings.items.*;
import net.einsteinsci.betterbeginnings.items.ItemBBCloth;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
|
package net.einsteinsci.betterbeginnings.register;
public class RegisterItems
{
public static final ToolMaterial NOOBWOOD = EnumHelper.addToolMaterial("NOOBWOOD", 0, 60, 2.0f, -4, 35);
public static final ItemNoobWoodSword noobWoodSword = new ItemNoobWoodSword(NOOBWOOD);
public static final ItemKnife flintKnife = new ItemKnifeFlint();
public static final ItemKnife boneKnife = new ItemKnifeBone();
public static final ItemKnife ironKnife = new ItemKnifeIron();
public static final ItemKnife diamondKnife = new ItemKnifeDiamond();
public static final ItemKnife goldKnife = new ItemKnifeGold();
public static final ItemFlintHatchet flintHatchet = new ItemFlintHatchet();
public static final ItemBonePickaxe bonePickaxe = new ItemBonePickaxe();
public static final ItemBoneShard boneShard = new ItemBoneShard();
public static final ItemTestItem testItem = new ItemTestItem();
public static final ItemSilk silk = new ItemSilk();
public static final ItemThread thread = new ItemThread();
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemBBCloth.java
// public class ItemBBCloth extends Item implements IBBName
// {
// public ItemBBCloth()
// {
// super();
//
// setUnlocalizedName("cloth");
//
// setCreativeTab(ModMain.tabBetterBeginnings);
// }
//
// @Override
// public String getName()
// {
// return "cloth";
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/RegisterItems.java
import net.einsteinsci.betterbeginnings.items.*;
import net.einsteinsci.betterbeginnings.items.ItemBBCloth;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.*;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
package net.einsteinsci.betterbeginnings.register;
public class RegisterItems
{
public static final ToolMaterial NOOBWOOD = EnumHelper.addToolMaterial("NOOBWOOD", 0, 60, 2.0f, -4, 35);
public static final ItemNoobWoodSword noobWoodSword = new ItemNoobWoodSword(NOOBWOOD);
public static final ItemKnife flintKnife = new ItemKnifeFlint();
public static final ItemKnife boneKnife = new ItemKnifeBone();
public static final ItemKnife ironKnife = new ItemKnifeIron();
public static final ItemKnife diamondKnife = new ItemKnifeDiamond();
public static final ItemKnife goldKnife = new ItemKnifeGold();
public static final ItemFlintHatchet flintHatchet = new ItemFlintHatchet();
public static final ItemBonePickaxe bonePickaxe = new ItemBonePickaxe();
public static final ItemBoneShard boneShard = new ItemBoneShard();
public static final ItemTestItem testItem = new ItemTestItem();
public static final ItemSilk silk = new ItemSilk();
public static final ItemThread thread = new ItemThread();
|
public static final ItemBBCloth cloth = new ItemBBCloth();
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
|
package net.einsteinsci.betterbeginnings.config.json;
public class RemovalConfig implements IJsonConfig
{
public static final RemovalConfig INSTANCE = new RemovalConfig();
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
package net.einsteinsci.betterbeginnings.config.json;
public class RemovalConfig implements IJsonConfig
{
public static final RemovalConfig INSTANCE = new RemovalConfig();
|
private JsonRemoveRecipesHandler customRecipes = new JsonRemoveRecipesHandler();
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
|
File customf = new File(subfolder, "custom.json");
String json = FileUtil.readAllText(customf);
if (json == null)
{
json = "{}";
}
return json;
}
@Override
public List<String> getIncludedJson(File subfolder)
{
List<String> res = new ArrayList<>();
for (String fileName : customRecipes.getIncludes())
{
File incf = new File(subfolder, fileName);
String json = FileUtil.readAllText(incf);
res.add(json);
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
File customf = new File(subfolder, "custom.json");
String json = FileUtil.readAllText(customf);
if (json == null)
{
json = "{}";
}
return json;
}
@Override
public List<String> getIncludedJson(File subfolder)
{
List<String> res = new ArrayList<>();
for (String fileName : customRecipes.getIncludes())
{
File incf = new File(subfolder, fileName);
String json = FileUtil.readAllText(incf);
res.add(json);
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
|
for (JsonRemovedCraftingRecipe r : customRecipes.getCraftingRemoved())
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
|
json = "{}";
}
return json;
}
@Override
public List<String> getIncludedJson(File subfolder)
{
List<String> res = new ArrayList<>();
for (String fileName : customRecipes.getIncludes())
{
File incf = new File(subfolder, fileName);
String json = FileUtil.readAllText(incf);
res.add(json);
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
for (JsonRemovedCraftingRecipe r : customRecipes.getCraftingRemoved())
{
r.register();
}
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
json = "{}";
}
return json;
}
@Override
public List<String> getIncludedJson(File subfolder)
{
List<String> res = new ArrayList<>();
for (String fileName : customRecipes.getIncludes())
{
File incf = new File(subfolder, fileName);
String json = FileUtil.readAllText(incf);
res.add(json);
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
for (JsonRemovedCraftingRecipe r : customRecipes.getCraftingRemoved())
{
r.register();
}
|
for (JsonRemovedSmeltingRecipe r : customRecipes.getSmeltingRemoved())
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
|
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
|
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
for (JsonRemovedCraftingRecipe r : customRecipes.getCraftingRemoved())
{
r.register();
}
for (JsonRemovedSmeltingRecipe r : customRecipes.getSmeltingRemoved())
{
r.register();
}
}
@Override
public void loadIncludedConfig(FMLInitializationEvent e, List<String> includedJsons)
{
for (String json : includedJsons)
{
JsonRemoveRecipesHandler handler = BBJsonLoader.deserializeObject(json, JsonRemoveRecipesHandler.class);
if (handler == null)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemoveRecipesHandler.java
// public class JsonRemoveRecipesHandler
// {
// List<JsonRemovedCraftingRecipe> craftingRemoved = new ArrayList<>();
// List<JsonRemovedSmeltingRecipe> smeltingRemoved = new ArrayList<>();
//
// List<String> includes = new ArrayList<>();
// List<String> modDependencies = new ArrayList<>();
//
// String __COMMENT = "Add items whose recipes you want to remove above. This does not affect recipes removed by " +
// "BetterBeginnings through regular config. Some examples are provided above (both of which have no recipe already).";
//
// public JsonRemoveRecipesHandler()
// {
// // Some examples
// craftingRemoved.add(new JsonRemovedCraftingRecipe(new ItemStack(Blocks.barrier)));
// smeltingRemoved.add(new JsonRemovedSmeltingRecipe(new ItemStack(RegisterItems.testItem)));
// }
//
// public List<JsonRemovedCraftingRecipe> getCraftingRemoved()
// {
// return craftingRemoved;
// }
//
// public List<JsonRemovedSmeltingRecipe> getSmeltingRemoved()
// {
// return smeltingRemoved;
// }
//
// public List<String> getIncludes()
// {
// return includes;
// }
//
// public List<String> getModDependencies()
// {
// return modDependencies;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedCraftingRecipe.java
// public class JsonRemovedCraftingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedCraftingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedCraftingRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/recipe/JsonRemovedSmeltingRecipe.java
// public class JsonRemovedSmeltingRecipe
// {
// public JsonLoadedItem removedItem;
//
// public JsonRemovedSmeltingRecipe(ItemStack stack)
// {
// removedItem = new JsonLoadedItem(stack);
// }
//
// public void register()
// {
// for (ItemStack rem : removedItem.getItemStacks())
// {
// RemoveRecipes.getCustomRemovedFurnaceRecipes().add(rem);
// }
// }
//
// public JsonLoadedItem getRemovedItem()
// {
// return removedItem;
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/config/json/RemovalConfig.java
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemoveRecipesHandler;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedCraftingRecipe;
import net.einsteinsci.betterbeginnings.config.json.recipe.JsonRemovedSmeltingRecipe;
import net.einsteinsci.betterbeginnings.util.FileUtil;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import org.apache.logging.log4j.Level;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
}
return res;
}
@Override
public void loadJsonConfig(FMLInitializationEvent e, String mainJson, String autoJson, String customJson)
{
// no main, only custom.
customRecipes = BBJsonLoader.deserializeObject(customJson, JsonRemoveRecipesHandler.class);
for (JsonRemovedCraftingRecipe r : customRecipes.getCraftingRemoved())
{
r.register();
}
for (JsonRemovedSmeltingRecipe r : customRecipes.getSmeltingRemoved())
{
r.register();
}
}
@Override
public void loadIncludedConfig(FMLInitializationEvent e, List<String> includedJsons)
{
for (String json : includedJsons)
{
JsonRemoveRecipesHandler handler = BBJsonLoader.deserializeObject(json, JsonRemoveRecipesHandler.class);
if (handler == null)
{
|
LogUtil.log(Level.ERROR, "Could not deserialize included json.");
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/BrickOvenRecipeHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
|
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
|
public BrickOvenShapelessRecipe putShapelessRecipe(ItemStack output, Object... args)
{
ArrayList res = new ArrayList();
for (Object obj : args)
{
if (obj instanceof ItemStack)
{
res.add(new OreRecipeElement((ItemStack)obj));
}
else if (obj instanceof Item)
{
res.add(new OreRecipeElement(new ItemStack((Item)obj)));
}
else if (obj instanceof Block)
{
res.add(new OreRecipeElement(new ItemStack((Block)obj)));
}
else if (obj instanceof String)
{
res.add(new OreRecipeElement((String)obj));
}
else if(obj instanceof OreRecipeElement)
{
res.add(obj);
}
else
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/BrickOvenRecipeHandler.java
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
public BrickOvenShapelessRecipe putShapelessRecipe(ItemStack output, Object... args)
{
ArrayList res = new ArrayList();
for (Object obj : args)
{
if (obj instanceof ItemStack)
{
res.add(new OreRecipeElement((ItemStack)obj));
}
else if (obj instanceof Item)
{
res.add(new OreRecipeElement(new ItemStack((Item)obj)));
}
else if (obj instanceof Block)
{
res.add(new OreRecipeElement(new ItemStack((Block)obj)));
}
else if (obj instanceof String)
{
res.add(new OreRecipeElement((String)obj));
}
else if(obj instanceof OreRecipeElement)
{
res.add(obj);
}
else
{
|
LogUtil.log(Level.WARN, "Invalid shapeless recipe!");
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/register/recipe/BrickOvenRecipeHandler.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
|
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
|
for (IBrickOvenRecipe recipe : recipes)
{
// IBrickOvenRecipe recipe = (IBrickOvenRecipe)recipes.get(j);
if (recipe.matches(oven))
{
return recipe.getCraftingResult(oven);
}
}
return null;
}
public boolean isInRecipe(ItemStack stack)
{
for (IBrickOvenRecipe recipe : recipes)
{
if (recipe.contains(stack))
{
return true;
}
}
return false;
}
public boolean existsRecipeFor(ItemStack stack)
{
for (IBrickOvenRecipe recipe : recipes)
{
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/LogUtil.java
// public class LogUtil
// {
// public static void logDebug(String text)
// {
// if (BBConfig.debugLogging)
// {
// log(Level.DEBUG, text);
// }
// }
//
// public static void logDebug(Level level, String text)
// {
// if (BBConfig.debugLogging)
// {
// log(level, text);
// }
// }
//
// public static void log(Level level, String text)
// {
// FMLLog.log(ModMain.NAME, level, text);
// }
//
// public static void log(String text)
// {
// log(Level.INFO, text);
// }
// }
//
// Path: src/main/java/net/einsteinsci/betterbeginnings/util/Util.java
// public class Util
// {
// public static boolean areItemStacksEqualIgnoreSize(ItemStack template, ItemStack tested)
// {
// if (template == null)
// {
// return tested == null;
// }
// else if (tested == null)
// {
// return false;
// }
//
// return template.getItem() == tested.getItem() && (template.getMetadata() == tested.getMetadata() ||
// template.getMetadata() == OreDictionary.WILDCARD_VALUE);
// }
//
// public static <TObject, TField> TField getPrivateVariable(TObject obj, String fieldName)
// {
// Field privateStringField = null;
// try
// {
// privateStringField = obj.getClass().getDeclaredField(fieldName);
// }
// catch (NoSuchFieldException e)
// {
// return null;
// }
// privateStringField.setAccessible(true);
//
// try
// {
// return (TField)privateStringField.get(obj);
// }
// catch (IllegalAccessException e)
// {
// return null;
// }
// }
//
// public static boolean listContainsItemStackIgnoreSize(List<ItemStack> list, ItemStack stack)
// {
// for (ItemStack s : list)
// {
// if (areItemStacksEqualIgnoreSize(s, stack))
// {
// return true;
// }
// }
//
// return false;
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/register/recipe/BrickOvenRecipeHandler.java
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
import net.einsteinsci.betterbeginnings.util.LogUtil;
import net.einsteinsci.betterbeginnings.util.Util;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.logging.log4j.Level;
import java.util.*;
for (IBrickOvenRecipe recipe : recipes)
{
// IBrickOvenRecipe recipe = (IBrickOvenRecipe)recipes.get(j);
if (recipe.matches(oven))
{
return recipe.getCraftingResult(oven);
}
}
return null;
}
public boolean isInRecipe(ItemStack stack)
{
for (IBrickOvenRecipe recipe : recipes)
{
if (recipe.contains(stack))
{
return true;
}
}
return false;
}
public boolean existsRecipeFor(ItemStack stack)
{
for (IBrickOvenRecipe recipe : recipes)
{
|
if (Util.areItemStacksEqualIgnoreSize(recipe.getRecipeOutput(), stack))
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemMarshmallow.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemFood;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemMarshmallow extends ItemFood implements IBBName
{
public ItemMarshmallow()
{
super(1, 2.0f, false);
setUnlocalizedName("marshmallow");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemMarshmallow.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemFood;
package net.einsteinsci.betterbeginnings.items;
public class ItemMarshmallow extends ItemFood implements IBBName
{
public ItemMarshmallow()
{
super(1, 2.0f, false);
setUnlocalizedName("marshmallow");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
einsteinsci/betterbeginnings
|
src/main/java/net/einsteinsci/betterbeginnings/items/ItemBonePickaxe.java
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
|
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import java.util.HashSet;
import java.util.Set;
|
package net.einsteinsci.betterbeginnings.items;
public class ItemBonePickaxe extends ItemPickaxe implements IBBName
{
public ItemBonePickaxe()
{
super(ToolMaterial.WOOD);
setUnlocalizedName("bonePickaxe");
|
// Path: src/main/java/net/einsteinsci/betterbeginnings/ModMain.java
// @Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
// guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
// public class ModMain
// {
// public static final String MODID = "betterbeginnings";
// public static final String VERSION = "0.9.8-pre1";
// public static final String NAME = "BetterBeginnings";
//
// @Instance(ModMain.MODID)
// public static ModMain modInstance;
//
// public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
// {
// @Override
// @SideOnly(Side.CLIENT)
// public Item getTabIconItem()
// {
// return RegisterItems.flintKnife;
// }
// };
//
// public static Configuration configFile;
//
// public BBEventHandler eventHandler = new BBEventHandler();
//
// @SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
// serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
// public static ServerProxy proxy;
// public static SimpleNetworkWrapper network;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent e)
// {
// LogUtil.logDebug("Starting pre-initialization...");
//
// configFile = BBConfigFolderLoader.getConfigFile(e);
// configFile.load();
// BBConfig.initialize();
// BBConfig.syncConfig(configFile);
//
// proxy.preInit(e);
//
// FMLCommonHandler.instance().bus().register(eventHandler);
// MinecraftForge.EVENT_BUS.register(eventHandler);
//
// network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
// network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
// PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
// network.registerMessage(PacketCampfireState.PacketHandler.class,
// PacketCampfireState.class, 1, Side.CLIENT);
//
// RegisterItems.register();
// RegisterBlocks.register();
// RegisterEntities.register();
// RegisterTileEntities.register();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent e)
// {
// proxy.init(e);
//
// BBConfigFolderLoader.loadRemovedRecipes(e);
//
// RemoveRecipes.remove();
// if (BBConfig.moduleFurnaces)
// {
// RemoveRecipes.removeFurnaceRecipes();
// }
//
// RegisterRecipes.addShapelessRecipes();
// RegisterRecipes.addShapedRecipes();
// RegisterRecipes.addAdvancedRecipes();
// RegisterRecipes.addFurnaceRecipes();
// InfusionRepairUtil.registerVanillaEnchantsConfig();
// TileEntitySmelterBase.registerDefaultBoosters();
//
// BBConfigFolderLoader.loadRecipes(e);
//
// if (e.getSide() == Side.CLIENT)
// {
// RegisterModels.register();
// }
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent e)
// {
// BBConfig.fillAlwaysBreakable();
// BBConfig.fillAlsoPickaxes();
// BBConfig.fillAlsoAxes();
//
// RegisterItems.tweakVanilla();
// Worldgen.addWorldgen();
// AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
// LogUtil.logDebug("Finished post-initialization.");
// }
//
// @EventHandler
// public void serverLoad(FMLServerStartingEvent e)
// {
// e.registerServerCommand(new JsonGenerateCommand());
// }
// }
// Path: src/main/java/net/einsteinsci/betterbeginnings/items/ItemBonePickaxe.java
import net.einsteinsci.betterbeginnings.ModMain;
import net.einsteinsci.betterbeginnings.register.IBBName;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import java.util.HashSet;
import java.util.Set;
package net.einsteinsci.betterbeginnings.items;
public class ItemBonePickaxe extends ItemPickaxe implements IBBName
{
public ItemBonePickaxe()
{
super(ToolMaterial.WOOD);
setUnlocalizedName("bonePickaxe");
|
setCreativeTab(ModMain.tabBetterBeginnings);
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
|
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import lombok.Data;
import java.util.Set;
|
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class ErrorResponse {
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import lombok.Data;
import java.util.Set;
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class ErrorResponse {
|
private Set<I18nMessage> errors;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
|
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
|
@ValidEnum(conformsTo = PaymentIntent.class)
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
|
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
@ValidEnum(conformsTo = PaymentIntent.class)
private String paymentIntent;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
@ValidEnum(conformsTo = PaymentIntent.class)
private String paymentIntent;
|
@ValidEnum(conformsTo = PaymentMethod.class)
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
|
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
@ValidEnum(conformsTo = PaymentIntent.class)
private String paymentIntent;
@ValidEnum(conformsTo = PaymentMethod.class)
private String paymentMethod;
@Valid
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import com.github.sandokandias.payments.infrastructure.util.validation.ValidEnum;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
package com.github.sandokandias.payments.interfaces.rest.model;
@Data
public class PerformPaymentRequest {
@NotNull
private String customerId;
@ValidEnum(conformsTo = PaymentIntent.class)
private String paymentIntent;
@ValidEnum(conformsTo = PaymentMethod.class)
private String paymentMethod;
@Valid
|
private Transaction transaction;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
|
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
|
private final PaymentProcessManager paymentProcessManager;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
|
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
|
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
|
PerformPayment performPayment = PerformPayment.commandOf(
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
|
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
PerformPayment performPayment = PerformPayment.commandOf(
new CustomerId(request.getCustomerId()),
PaymentIntent.valueOf(request.getPaymentIntent()),
PaymentMethod.valueOf(request.getPaymentMethod()),
request.getTransaction());
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
PerformPayment performPayment = PerformPayment.commandOf(
new CustomerId(request.getCustomerId()),
PaymentIntent.valueOf(request.getPaymentIntent()),
PaymentMethod.valueOf(request.getPaymentMethod()),
request.getTransaction());
|
CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> promise = paymentProcessManager.process(performPayment);
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
|
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
PerformPayment performPayment = PerformPayment.commandOf(
new CustomerId(request.getCustomerId()),
PaymentIntent.valueOf(request.getPaymentIntent()),
PaymentMethod.valueOf(request.getPaymentMethod()),
request.getTransaction());
CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> promise = paymentProcessManager.process(performPayment);
return promise.thenApply(acceptOrReject -> acceptOrReject.fold(
reject -> ResponseEntity.badRequest().body(reject),
|
// Path: src/main/java/com/github/sandokandias/payments/application/PaymentProcessManager.java
// public interface PaymentProcessManager {
// CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> process(PerformPayment command);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentRequest.java
// @Data
// public class PerformPaymentRequest {
// @NotNull
// private String customerId;
// @ValidEnum(conformsTo = PaymentIntent.class)
// private String paymentIntent;
// @ValidEnum(conformsTo = PaymentMethod.class)
// private String paymentMethod;
// @Valid
// private Transaction transaction;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/PerformPaymentResponse.java
// @AllArgsConstructor
// @Setter
// @Getter
// public class PerformPaymentResponse {
// private String paymentId;
// private String status;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/PaymentController.java
import com.github.sandokandias.payments.application.PaymentProcessManager;
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.vo.*;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentRequest;
import com.github.sandokandias.payments.interfaces.rest.model.PerformPaymentResponse;
import io.vavr.Tuple2;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.interfaces.rest.controller;
@RestController("/v1/payments")
public class PaymentController {
private static final Logger LOG = LoggerFactory.getLogger(PaymentController.class);
private final PaymentProcessManager paymentProcessManager;
public PaymentController(PaymentProcessManager paymentProcessManager) {
this.paymentProcessManager = paymentProcessManager;
}
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Callable<CompletionStage<ResponseEntity<?>>> process(@Valid @RequestBody PerformPaymentRequest request) {
LOG.debug("Request {}", request);
return () -> {
LOG.debug("Callable...");
PerformPayment performPayment = PerformPayment.commandOf(
new CustomerId(request.getCustomerId()),
PaymentIntent.valueOf(request.getPaymentIntent()),
PaymentMethod.valueOf(request.getPaymentMethod()),
request.getTransaction());
CompletionStage<Either<CommandFailure, Tuple2<PaymentId, PaymentStatus>>> promise = paymentProcessManager.process(performPayment);
return promise.thenApply(acceptOrReject -> acceptOrReject.fold(
reject -> ResponseEntity.badRequest().body(reject),
|
accept -> ResponseEntity.accepted().body(new PerformPaymentResponse(accept._1.id, accept._2.name()))
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/Event.java
// public interface Event extends Serializable{
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.shared.Event;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
public interface PaymentEvent extends Event {
PaymentEventId getEventId();
|
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/Event.java
// public interface Event extends Serializable{
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
import com.github.sandokandias.payments.domain.shared.Event;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
public interface PaymentEvent extends Event {
PaymentEventId getEventId();
|
PaymentEventType getEventType();
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/Event.java
// public interface Event extends Serializable{
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.shared.Event;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
public interface PaymentEvent extends Event {
PaymentEventId getEventId();
PaymentEventType getEventType();
|
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/Event.java
// public interface Event extends Serializable{
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
import com.github.sandokandias.payments.domain.shared.Event;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
public interface PaymentEvent extends Event {
PaymentEventId getEventId();
PaymentEventType getEventType();
|
PaymentId getPaymentId();
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandValidation.java
// public interface CommandValidation<C extends Command> {
//
// Either<CommandFailure, C> acceptOrReject(C command);
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandValidation;
import io.vavr.control.Either;
import org.springframework.stereotype.Component;
|
package com.github.sandokandias.payments.domain.command.validation;
@Component
public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandValidation.java
// public interface CommandValidation<C extends Command> {
//
// Either<CommandFailure, C> acceptOrReject(C command);
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandValidation;
import io.vavr.control.Either;
import org.springframework.stereotype.Component;
package com.github.sandokandias.payments.domain.command.validation;
@Component
public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
@Override
|
public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
|
private final PaymentId paymentId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
|
private final CustomerId customerId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
private final CustomerId customerId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
private final CustomerId customerId;
|
private final PaymentMethod paymentMethod;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
private final CustomerId customerId;
private final PaymentMethod paymentMethod;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class AuthorizePayment implements PaymentCommand {
private final PaymentId paymentId;
private final CustomerId customerId;
private final PaymentMethod paymentMethod;
|
private final Transaction transaction;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nCode.java
// public class I18nCode {
// public final String code;
// public final Object[] args;
//
// public I18nCode(String code, Object... args) {
// this.code = code;
// this.args = args;
// }
// }
|
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nCode;
import lombok.AllArgsConstructor;
import java.util.Set;
|
package com.github.sandokandias.payments.domain.shared;
@AllArgsConstructor
public class CommandFailure {
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nCode.java
// public class I18nCode {
// public final String code;
// public final Object[] args;
//
// public I18nCode(String code, Object... args) {
// this.code = code;
// this.args = args;
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nCode;
import lombok.AllArgsConstructor;
import java.util.Set;
package com.github.sandokandias.payments.domain.shared;
@AllArgsConstructor
public class CommandFailure {
|
public final Set<I18nCode> codes;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandValidation.java
// public interface CommandValidation<C extends Command> {
//
// Either<CommandFailure, C> acceptOrReject(C command);
// }
|
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandValidation;
import io.vavr.control.Either;
import org.springframework.stereotype.Component;
|
package com.github.sandokandias.payments.domain.command.validation;
@Component
public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandValidation.java
// public interface CommandValidation<C extends Command> {
//
// Either<CommandFailure, C> acceptOrReject(C command);
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandValidation;
import io.vavr.control.Either;
import org.springframework.stereotype.Component;
package com.github.sandokandias.payments.domain.command.validation;
@Component
public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
@Override
|
public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
|
private final PaymentEventRepository paymentEventRepository;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
public ConfirmPaymentHandler(PaymentEventRepository paymentEventRepository) {
this.paymentEventRepository = paymentEventRepository;
}
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
public ConfirmPaymentHandler(PaymentEventRepository paymentEventRepository) {
this.paymentEventRepository = paymentEventRepository;
}
@Override
|
public CompletionStage<Either<CommandFailure, PaymentConfirmed>> handle(ConfirmPayment command, PaymentId entityId) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
public ConfirmPaymentHandler(PaymentEventRepository paymentEventRepository) {
this.paymentEventRepository = paymentEventRepository;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentConfirmed>> handle(ConfirmPayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
PaymentConfirmed event = PaymentConfirmed.eventOf(
entityId,
command.getCustomerId(),
command.getTimestamp()
);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
// @Value(staticConstructor = "commandOf")
// public class ConfirmPayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
// @Value(staticConstructor = "eventOf")
// public class PaymentConfirmed implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_CONFIRMED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/ConfirmPaymentHandler.java
import com.github.sandokandias.payments.domain.command.ConfirmPayment;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentConfirmed;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class ConfirmPaymentHandler implements CommandHandler<ConfirmPayment, PaymentConfirmed, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(ConfirmPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
public ConfirmPaymentHandler(PaymentEventRepository paymentEventRepository) {
this.paymentEventRepository = paymentEventRepository;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentConfirmed>> handle(ConfirmPayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
PaymentConfirmed event = PaymentConfirmed.eventOf(
entityId,
command.getCustomerId(),
command.getTimestamp()
);
|
CompletionStage<PaymentEventId> storePromise = paymentEventRepository.store(event);
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
|
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
|
private final JsonMapper jsonMapper;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
|
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
|
public CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
|
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
|
public CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
|
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
public CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent) {
LOG.debug("Storing paymentEvent {}", paymentEvent);
String eventDataAsJson = jsonMapper.write(paymentEvent);
LOG.debug("eventDataAsJson {}", eventDataAsJson);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentEvent.java
// public interface PaymentEvent extends Event {
// PaymentEventId getEventId();
//
// PaymentEventType getEventType();
//
// PaymentId getPaymentId();
//
// LocalDateTime getTimestamp();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
// @NoArgsConstructor
// @Getter
// @Setter
// @EqualsAndHashCode(exclude = {"eventData", "timestamp"})
// @ToString
// @Entity
// @Table
// public class PaymentEventTable {
// @PrimaryKey
// @Id
// private String eventId;
// private PaymentEventType eventType;
// private String paymentId;
// private LocalDateTime timestamp;
// @Column(length = 1024)
// private String eventData;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/json/JsonMapper.java
// @Component
// public class JsonMapper {
//
// private final ObjectMapper MAPPER;
//
// public JsonMapper() {
// MAPPER = new ObjectMapper();
// MAPPER.registerModule(new JavaTimeModule());
// MAPPER.registerModule(new Jdk8Module());
// MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// MAPPER.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
// }
//
// public <T> T read(Object json, Class<T> tClass) {
// return MAPPER.convertValue(json, tClass);
// }
//
// public <T> String write(T model) {
// try {
// return MAPPER.writeValueAsString(model);
// } catch (JsonProcessingException e) {
// throw new RuntimeException(e);
// }
// }
//
//
// }
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/repository/PaymentEventRepositoryImpl.java
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentEvent;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.infrastructure.persistence.mapping.PaymentEventTable;
import com.github.sandokandias.payments.infrastructure.util.json.JsonMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.infrastructure.persistence.repository;
@Repository
class PaymentEventRepositoryImpl implements PaymentEventRepository {
private static final Logger LOG = LoggerFactory.getLogger(PaymentEventRepositoryImpl.class);
private final EventStore eventStore;
private final JsonMapper jsonMapper;
PaymentEventRepositoryImpl(EventStore eventStore,
JsonMapper jsonMapper) {
this.eventStore = eventStore;
this.jsonMapper = jsonMapper;
}
@Override
public CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent) {
LOG.debug("Storing paymentEvent {}", paymentEvent);
String eventDataAsJson = jsonMapper.write(paymentEvent);
LOG.debug("eventDataAsJson {}", eventDataAsJson);
|
PaymentEventTable paymentEventTable = new PaymentEventTable();
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
|
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
|
private final PaymentEventRepository paymentEventRepository;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
|
private final PerformPaymentValidator performPaymentValidator;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final PerformPaymentValidator performPaymentValidator;
PerformPaymentHandler(PaymentEventRepository paymentEventRepository,
PerformPaymentValidator performPaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.performPaymentValidator = performPaymentValidator;
}
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final PerformPaymentValidator performPaymentValidator;
PerformPaymentHandler(PaymentEventRepository paymentEventRepository,
PerformPaymentValidator performPaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.performPaymentValidator = performPaymentValidator;
}
@Override
|
public CompletionStage<Either<CommandFailure, PaymentRequested>> handle(PerformPayment command, PaymentId entityId) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final PerformPaymentValidator performPaymentValidator;
PerformPaymentHandler(PaymentEventRepository paymentEventRepository,
PerformPaymentValidator performPaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.performPaymentValidator = performPaymentValidator;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentRequested>> handle(PerformPayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
return performPaymentValidator.acceptOrReject(command).fold(
reject -> CompletableFuture.completedFuture(Either.left(reject)),
accept -> {
PaymentRequested event = PaymentRequested.eventOf(
entityId,
command.getCustomerId(),
command.getPaymentIntent(),
command.getPaymentMethod(),
command.getTransaction(),
command.getTimestamp()
);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
// @Value(staticConstructor = "commandOf")
// public class PerformPayment implements PaymentCommand {
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/PerformPaymentValidator.java
// @Component
// public class PerformPaymentValidator implements CommandValidation<PerformPayment> {
//
// @Override
// public Either<CommandFailure, PerformPayment> acceptOrReject(PerformPayment command) {
//
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentRequested.java
// @Value(staticConstructor = "eventOf")
// public class PaymentRequested implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentIntent paymentIntent;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_REQUESTED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/PerformPaymentHandler.java
import com.github.sandokandias.payments.domain.command.PerformPayment;
import com.github.sandokandias.payments.domain.command.validation.PerformPaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentRequested;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class PerformPaymentHandler implements
CommandHandler<PerformPayment, PaymentRequested, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(PerformPaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final PerformPaymentValidator performPaymentValidator;
PerformPaymentHandler(PaymentEventRepository paymentEventRepository,
PerformPaymentValidator performPaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.performPaymentValidator = performPaymentValidator;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentRequested>> handle(PerformPayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
return performPaymentValidator.acceptOrReject(command).fold(
reject -> CompletableFuture.completedFuture(Either.left(reject)),
accept -> {
PaymentRequested event = PaymentRequested.eventOf(
entityId,
command.getCustomerId(),
command.getPaymentIntent(),
command.getPaymentMethod(),
command.getTransaction(),
command.getTimestamp()
);
|
CompletionStage<PaymentEventId> storePromise = paymentEventRepository.store(event);
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class ConfirmPayment implements PaymentCommand {
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class ConfirmPayment implements PaymentCommand {
|
private final PaymentId paymentId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class ConfirmPayment implements PaymentCommand {
private final PaymentId paymentId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/ConfirmPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class ConfirmPayment implements PaymentCommand {
private final PaymentId paymentId;
|
private final CustomerId customerId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
|
private final PaymentEventId eventId = new PaymentEventId();
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
|
private final PaymentId paymentId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
private final PaymentId paymentId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
private final PaymentId paymentId;
|
private final CustomerId customerId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
private final PaymentId paymentId;
private final CustomerId customerId;
private final LocalDateTime timestamp;
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentConfirmed.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.event;
@Value(staticConstructor = "eventOf")
public class PaymentConfirmed implements PaymentEvent {
private final PaymentEventId eventId = new PaymentEventId();
private final PaymentId paymentId;
private final CustomerId customerId;
private final LocalDateTime timestamp;
@Override
|
public PaymentEventType getEventType() {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/DefaultExceptionHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
// @Data
// public class ErrorResponse {
// private Set<I18nMessage> errors;
// }
|
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import com.github.sandokandias.payments.interfaces.rest.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@ControllerAdvice
public class DefaultExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(DefaultExceptionHandler.class);
private final MessageSource messageSource;
public DefaultExceptionHandler(MessageSource messageSource) {
this.messageSource = messageSource;
}
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<Object> handle(MethodArgumentNotValidException exception) {
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
// @Data
// public class ErrorResponse {
// private Set<I18nMessage> errors;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/DefaultExceptionHandler.java
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import com.github.sandokandias.payments.interfaces.rest.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
package com.github.sandokandias.payments.interfaces.rest.controller;
@ControllerAdvice
public class DefaultExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(DefaultExceptionHandler.class);
private final MessageSource messageSource;
public DefaultExceptionHandler(MessageSource messageSource) {
this.messageSource = messageSource;
}
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<Object> handle(MethodArgumentNotValidException exception) {
|
Set<I18nMessage> errors = exception.getBindingResult().getFieldErrors().stream()
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/DefaultExceptionHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
// @Data
// public class ErrorResponse {
// private Set<I18nMessage> errors;
// }
|
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import com.github.sandokandias.payments.interfaces.rest.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
|
package com.github.sandokandias.payments.interfaces.rest.controller;
@ControllerAdvice
public class DefaultExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(DefaultExceptionHandler.class);
private final MessageSource messageSource;
public DefaultExceptionHandler(MessageSource messageSource) {
this.messageSource = messageSource;
}
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<Object> handle(MethodArgumentNotValidException exception) {
Set<I18nMessage> errors = exception.getBindingResult().getFieldErrors().stream()
.map(e -> {
String field = e.getField();
Object rejectedValue = e.getRejectedValue();
String code = e.getCode();
Locale locale = LocaleContextHolder.getLocale();
I18nMessage msg = new I18nMessage();
msg.setField(field);
msg.setRejectedValue(rejectedValue);
msg.setMessage(messageSource.getMessage(code, new Object[]{rejectedValue}, locale));
return msg;
})
.collect(Collectors.toSet());
|
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/util/i18n/I18nMessage.java
// @Data
// public class I18nMessage {
// private String field;
// private Object rejectedValue;
// private String message;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/model/ErrorResponse.java
// @Data
// public class ErrorResponse {
// private Set<I18nMessage> errors;
// }
// Path: src/main/java/com/github/sandokandias/payments/interfaces/rest/controller/DefaultExceptionHandler.java
import com.github.sandokandias.payments.infrastructure.util.i18n.I18nMessage;
import com.github.sandokandias.payments.interfaces.rest.model.ErrorResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
package com.github.sandokandias.payments.interfaces.rest.controller;
@ControllerAdvice
public class DefaultExceptionHandler {
private static final Logger LOG = LoggerFactory.getLogger(DefaultExceptionHandler.class);
private final MessageSource messageSource;
public DefaultExceptionHandler(MessageSource messageSource) {
this.messageSource = messageSource;
}
@ExceptionHandler(MethodArgumentNotValidException.class)
protected ResponseEntity<Object> handle(MethodArgumentNotValidException exception) {
Set<I18nMessage> errors = exception.getBindingResult().getFieldErrors().stream()
.map(e -> {
String field = e.getField();
Object rejectedValue = e.getRejectedValue();
String code = e.getCode();
Locale locale = LocaleContextHolder.getLocale();
I18nMessage msg = new I18nMessage();
msg.setField(field);
msg.setRejectedValue(rejectedValue);
msg.setMessage(messageSource.getMessage(code, new Object[]{rejectedValue}, locale));
return msg;
})
.collect(Collectors.toSet());
|
ErrorResponse errorResponse = new ErrorResponse();
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
|
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import lombok.*;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.infrastructure.persistence.mapping;
@NoArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(exclude = {"eventData", "timestamp"})
@ToString
@Entity
@Table
public class PaymentEventTable {
@PrimaryKey
@Id
private String eventId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventType.java
// public enum PaymentEventType {
// PAYMENT_REQUESTED,
// PAYMENT_AUTHORIZED,
// PAYMENT_CONFIRMED;
// }
// Path: src/main/java/com/github/sandokandias/payments/infrastructure/persistence/mapping/PaymentEventTable.java
import com.github.sandokandias.payments.domain.vo.PaymentEventType;
import lombok.*;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.infrastructure.persistence.mapping;
@NoArgsConstructor
@Getter
@Setter
@EqualsAndHashCode(exclude = {"eventData", "timestamp"})
@ToString
@Entity
@Table
public class PaymentEventTable {
@PrimaryKey
@Id
private String eventId;
|
private PaymentEventType eventType;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
|
private final CustomerId customerId;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
|
private final PaymentIntent paymentIntent;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
private final PaymentIntent paymentIntent;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
private final PaymentIntent paymentIntent;
|
private final PaymentMethod paymentMethod;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
|
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
|
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
private final PaymentIntent paymentIntent;
private final PaymentMethod paymentMethod;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/CustomerId.java
// public class CustomerId extends RandomUUID {
//
// public CustomerId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "CST-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentIntent.java
// public enum PaymentIntent {
// AUTHORIZE, CAPTURE;
//
// public boolean isAuthorize() {
// return AUTHORIZE.equals(this);
// }
//
// public boolean isCapture() {
// return CAPTURE.equals(this);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentMethod.java
// public enum PaymentMethod {
// CREDIT_CARD
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/Transaction.java
// public class Transaction implements ValueObject<Transaction> {
// @Valid
// public final Money amount;
// @NotNull
// @Size(min = 1)
// public final List<TransactionItem> items;
//
// @JsonCreator
// public Transaction(@JsonProperty("amount") Money amount,
// @JsonProperty("items") List<TransactionItem> items) {
//
// this.amount = amount;
// this.items = items;
// }
//
// @Override
// public boolean sameValueAs(Transaction other) {
// return other != null &&
// this.amount.sameValueAs(other.amount) &&
// this.items.size() == other.items.size() &&
// this.items.containsAll(other.items);
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/PerformPayment.java
import com.github.sandokandias.payments.domain.vo.CustomerId;
import com.github.sandokandias.payments.domain.vo.PaymentIntent;
import com.github.sandokandias.payments.domain.vo.PaymentMethod;
import com.github.sandokandias.payments.domain.vo.Transaction;
import lombok.Value;
import java.time.LocalDateTime;
package com.github.sandokandias.payments.domain.command;
@Value(staticConstructor = "commandOf")
public class PerformPayment implements PaymentCommand {
private final CustomerId customerId;
private final PaymentIntent paymentIntent;
private final PaymentMethod paymentMethod;
|
private final Transaction transaction;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
|
private final PaymentEventRepository paymentEventRepository;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
|
private final AuthorizePaymentValidator authorizePaymentValidator;
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final AuthorizePaymentValidator authorizePaymentValidator;
public AuthorizePaymentHandler(PaymentEventRepository paymentEventRepository,
AuthorizePaymentValidator authorizePaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.authorizePaymentValidator = authorizePaymentValidator;
}
@Override
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final AuthorizePaymentValidator authorizePaymentValidator;
public AuthorizePaymentHandler(PaymentEventRepository paymentEventRepository,
AuthorizePaymentValidator authorizePaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.authorizePaymentValidator = authorizePaymentValidator;
}
@Override
|
public CompletionStage<Either<CommandFailure, PaymentAuthorized>> handle(AuthorizePayment command, PaymentId entityId) {
|
sandokandias/spring-boot-ddd
|
src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
|
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
|
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final AuthorizePaymentValidator authorizePaymentValidator;
public AuthorizePaymentHandler(PaymentEventRepository paymentEventRepository,
AuthorizePaymentValidator authorizePaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.authorizePaymentValidator = authorizePaymentValidator;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentAuthorized>> handle(AuthorizePayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
return authorizePaymentValidator.acceptOrReject(command).fold(
reject -> CompletableFuture.completedFuture(Either.left(reject)),
accept -> {
PaymentAuthorized event = PaymentAuthorized.eventOf(
entityId,
command.getCustomerId(),
command.getPaymentMethod(),
command.getTransaction(),
command.getTimestamp()
);
|
// Path: src/main/java/com/github/sandokandias/payments/domain/command/AuthorizePayment.java
// @Value(staticConstructor = "commandOf")
// public class AuthorizePayment implements PaymentCommand {
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp = LocalDateTime.now();
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/command/validation/AuthorizePaymentValidator.java
// @Component
// public class AuthorizePaymentValidator implements CommandValidation<AuthorizePayment> {
//
// @Override
// public Either<CommandFailure, AuthorizePayment> acceptOrReject(AuthorizePayment command) {
// return Either.right(command);
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/entity/PaymentEventRepository.java
// public interface PaymentEventRepository {
// CompletionStage<PaymentEventId> store(PaymentEvent paymentEvent);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/event/PaymentAuthorized.java
// @Value(staticConstructor = "eventOf")
// public class PaymentAuthorized implements PaymentEvent {
// private final PaymentEventId eventId = new PaymentEventId();
// private final PaymentId paymentId;
// private final CustomerId customerId;
// private final PaymentMethod paymentMethod;
// private final Transaction transaction;
// private final LocalDateTime timestamp;
//
// @Override
// public PaymentEventType getEventType() {
// return PaymentEventType.PAYMENT_AUTHORIZED;
// }
//
// @Override
// public LocalDateTime getTimestamp() {
// return timestamp;
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandFailure.java
// @AllArgsConstructor
// public class CommandFailure {
// public final Set<I18nCode> codes;
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/shared/CommandHandler.java
// public interface CommandHandler<C extends Command, E extends Event, ID> {
// CompletionStage<Either<CommandFailure, E>> handle(C command, ID entityId);
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentEventId.java
// public class PaymentEventId extends RandomUUID {
//
// @Override
// protected String getPrefix() {
// return "PEV-%s";
// }
// }
//
// Path: src/main/java/com/github/sandokandias/payments/domain/vo/PaymentId.java
// public class PaymentId extends RandomUUID {
//
// public PaymentId() {
// super();
// }
//
// public PaymentId(String id) {
// super(id);
// }
//
// @Override
// protected String getPrefix() {
// return "PAY-%s";
// }
// }
// Path: src/main/java/com/github/sandokandias/payments/domain/command/handler/AuthorizePaymentHandler.java
import com.github.sandokandias.payments.domain.command.AuthorizePayment;
import com.github.sandokandias.payments.domain.command.validation.AuthorizePaymentValidator;
import com.github.sandokandias.payments.domain.entity.PaymentEventRepository;
import com.github.sandokandias.payments.domain.event.PaymentAuthorized;
import com.github.sandokandias.payments.domain.shared.CommandFailure;
import com.github.sandokandias.payments.domain.shared.CommandHandler;
import com.github.sandokandias.payments.domain.vo.PaymentEventId;
import com.github.sandokandias.payments.domain.vo.PaymentId;
import io.vavr.control.Either;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
package com.github.sandokandias.payments.domain.command.handler;
@Component
public class AuthorizePaymentHandler implements CommandHandler<AuthorizePayment, PaymentAuthorized, PaymentId> {
private static final Logger LOG = LoggerFactory.getLogger(AuthorizePaymentHandler.class);
private final PaymentEventRepository paymentEventRepository;
private final AuthorizePaymentValidator authorizePaymentValidator;
public AuthorizePaymentHandler(PaymentEventRepository paymentEventRepository,
AuthorizePaymentValidator authorizePaymentValidator) {
this.paymentEventRepository = paymentEventRepository;
this.authorizePaymentValidator = authorizePaymentValidator;
}
@Override
public CompletionStage<Either<CommandFailure, PaymentAuthorized>> handle(AuthorizePayment command, PaymentId entityId) {
LOG.debug("Handle command {}", command);
return authorizePaymentValidator.acceptOrReject(command).fold(
reject -> CompletableFuture.completedFuture(Either.left(reject)),
accept -> {
PaymentAuthorized event = PaymentAuthorized.eventOf(
entityId,
command.getCustomerId(),
command.getPaymentMethod(),
command.getTransaction(),
command.getTimestamp()
);
|
CompletionStage<PaymentEventId> storePromise = paymentEventRepository.store(event);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevoxxApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
|
import android.content.Context;
import com.nilhcem.devoxxfr.receiver.BootReceiver;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.ui.BasePresenter;
import com.nilhcem.devoxxfr.utils.App;
|
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsView> {
private final Context context;
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevoxxApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsPresenter.java
import android.content.Context;
import com.nilhcem.devoxxfr.receiver.BootReceiver;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.ui.BasePresenter;
import com.nilhcem.devoxxfr.utils.App;
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsView> {
private final Context context;
|
private final SessionsReminder sessionsReminder;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevoxxApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
|
import android.content.Context;
import com.nilhcem.devoxxfr.receiver.BootReceiver;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.ui.BasePresenter;
import com.nilhcem.devoxxfr.utils.App;
|
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsView> {
private final Context context;
private final SessionsReminder sessionsReminder;
public SettingsPresenter(Context context, SettingsView view, SessionsReminder sessionsReminder) {
super(view);
this.context = context;
this.sessionsReminder = sessionsReminder;
}
public void onCreate() {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevoxxApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/settings/SettingsPresenter.java
import android.content.Context;
import com.nilhcem.devoxxfr.receiver.BootReceiver;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import com.nilhcem.devoxxfr.ui.BasePresenter;
import com.nilhcem.devoxxfr.utils.App;
package com.nilhcem.devoxxfr.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsView> {
private final Context context;
private final SessionsReminder sessionsReminder;
public SettingsPresenter(Context context, SettingsView view, SessionsReminder sessionsReminder) {
super(view);
this.context = context;
this.sessionsReminder = sessionsReminder;
}
public void onCreate() {
|
view.setAppVersion(App.getVersion());
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
|
import android.app.Application;
import android.content.Context;
import com.jakewharton.threetenabp.AndroidThreeTen;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import hugo.weaving.DebugLog;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr;
@DebugLog
public class DevoxxApp extends Application {
|
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
// @Singleton
// @Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
// public interface AppComponent extends AppGraph {
//
// /**
// * An initializer that creates the production graph from an application.
// */
// final class Initializer {
//
// private Initializer() {
// throw new UnsupportedOperationException();
// }
//
// public static AppComponent init(DevoxxApp app) {
// return DaggerAppComponent.builder()
// .appModule(new AppModule(app))
// .apiModule(new ApiModule())
// .dataModule(new DataModule())
// .databaseModule(new DatabaseModule())
// .build();
// }
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
import android.app.Application;
import android.content.Context;
import com.jakewharton.threetenabp.AndroidThreeTen;
import com.nilhcem.devoxxfr.core.dagger.AppComponent;
import hugo.weaving.DebugLog;
import timber.log.Timber;
package com.nilhcem.devoxxfr;
@DebugLog
public class DevoxxApp extends Application {
|
private AppComponent component;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/ui/speakers/list/SpeakersListEntry.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/recyclerview/BaseViewHolder.java
// public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
//
// public BaseViewHolder(ViewGroup parent, @LayoutRes int layout) {
// super(LayoutInflater.from(parent.getContext()).inflate(layout, parent, false));
// ButterKnife.bind(this, itemView);
// }
// }
|
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.recyclerview.BaseViewHolder;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
|
package com.nilhcem.devoxxfr.ui.speakers.list;
public class SpeakersListEntry extends BaseViewHolder {
@Bind(R.id.speakers_list_entry_photo) ImageView photo;
@Bind(R.id.speakers_list_entry_name) TextView name;
private final Picasso picasso;
public SpeakersListEntry(ViewGroup parent, Picasso picasso) {
super(parent, R.layout.speakers_list_entry);
this.picasso = picasso;
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/core/recyclerview/BaseViewHolder.java
// public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
//
// public BaseViewHolder(ViewGroup parent, @LayoutRes int layout) {
// super(LayoutInflater.from(parent.getContext()).inflate(layout, parent, false));
// ButterKnife.bind(this, itemView);
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/speakers/list/SpeakersListEntry.java
import android.text.TextUtils;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import com.nilhcem.devoxxfr.ui.core.recyclerview.BaseViewHolder;
import com.squareup.picasso.Picasso;
import butterknife.Bind;
package com.nilhcem.devoxxfr.ui.speakers.list;
public class SpeakersListEntry extends BaseViewHolder {
@Bind(R.id.speakers_list_entry_photo) ImageView photo;
@Bind(R.id.speakers_list_entry_name) TextView name;
private final Picasso picasso;
public SpeakersListEntry(ViewGroup parent, Picasso picasso) {
super(parent, R.layout.speakers_list_entry);
this.picasso = picasso;
}
|
public void bindSpeaker(Speaker speaker) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/data/database/model/Speaker.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
|
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
|
package com.nilhcem.devoxxfr.data.database.model;
public class Speaker {
public static final String TABLE = "speakers";
public static final String ID = "_id";
public static final String NAME = "name";
public static final String TITLE = "title";
public static final String BIO = "bio";
public static final String WEBSITE = "website";
public static final String TWITTER = "twitter";
public static final String GITHUB = "github";
public static final String PHOTO = "photo";
public final int id;
public final String name;
public final String title;
public final String bio;
public final String website;
public final String twitter;
public final String github;
public final String photo;
public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
this.id = id;
this.name = name;
this.title = title;
this.bio = bio;
this.website = website;
this.twitter = twitter;
this.github = github;
this.photo = photo;
}
public static final Func1<Cursor, Speaker> MAPPER = cursor -> {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/utils/Database.java
// public class Database {
//
// public static String getString(Cursor cursor, String columnName) {
// return cursor.getString(cursor.getColumnIndexOrThrow(columnName));
// }
//
// public static int getInt(Cursor cursor, String columnName) {
// return cursor.getInt(cursor.getColumnIndexOrThrow(columnName));
// }
//
// private Database() {
// throw new UnsupportedOperationException();
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/database/model/Speaker.java
import android.content.ContentValues;
import android.database.Cursor;
import com.nilhcem.devoxxfr.utils.Database;
import rx.functions.Func1;
package com.nilhcem.devoxxfr.data.database.model;
public class Speaker {
public static final String TABLE = "speakers";
public static final String ID = "_id";
public static final String NAME = "name";
public static final String TITLE = "title";
public static final String BIO = "bio";
public static final String WEBSITE = "website";
public static final String TWITTER = "twitter";
public static final String GITHUB = "github";
public static final String PHOTO = "photo";
public final int id;
public final String name;
public final String title;
public final String bio;
public final String website;
public final String twitter;
public final String github;
public final String photo;
public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
this.id = id;
this.name = name;
this.title = title;
this.bio = bio;
this.website = website;
this.twitter = twitter;
this.github = github;
this.photo = photo;
}
public static final Func1<Cursor, Speaker> MAPPER = cursor -> {
|
int id = Database.getInt(cursor, ID);
|
Nilhcem/devoxxfr-2016
|
app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
// @Module
// public final class ApiModule {
//
// @Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
// return ApiEndpoint.get(context);
// }
//
// @Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
// return new Retrofit.Builder()
// .client(client)
// .baseUrl(endpoint.url)
// .addConverterFactory(MoshiConverterFactory.create(moshi))
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .build();
// }
//
// @Provides @Singleton DevoxxService provideDevoxxService(Retrofit retrofit) {
// return retrofit.create(DevoxxService.class);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
// @Module
// public final class AppModule {
//
// private final DevoxxApp app;
//
// public AppModule(DevoxxApp app) {
// this.app = app;
// }
//
// @Provides @Singleton Application provideApplication() {
// return app;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
// @Module(includes = OkHttpModule.class)
// public final class DataModule {
//
// private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
//
// @Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
// return PreferenceManager.getDefaultSharedPreferences(app);
// }
//
// @Provides @Singleton Moshi provideMoshi(LocalDateTimeAdapter localDateTimeAdapter) {
// return new Moshi.Builder()
// .add(localDateTimeAdapter)
// .build();
// }
//
// @Provides @Singleton OkHttpClient.Builder provideOkHttpClientBuilder(Application app) {
// File cacheDir = new File(app.getCacheDir(), "http");
// Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE);
// return new OkHttpClient.Builder().cache(cache);
// }
//
// @Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
// return new Picasso.Builder(app)
// .downloader(new OkHttp3Downloader(client))
// .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
// .build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
// @Module
// public class DatabaseModule {
//
// static final String TAG = "database";
//
// @Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
// return new DbOpenHelper(application);
// }
//
// @Provides @Singleton SqlBrite provideSqlBrite() {
// return SqlBrite.create(Timber.tag(TAG)::v);
// }
//
// @Provides @Singleton BriteDatabase provideBriteDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
// return sqlBrite.wrapDatabaseHelper(helper, Schedulers.immediate());
// }
// }
|
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.core.dagger.module.ApiModule;
import com.nilhcem.devoxxfr.core.dagger.module.AppModule;
import com.nilhcem.devoxxfr.core.dagger.module.DataModule;
import com.nilhcem.devoxxfr.core.dagger.module.DatabaseModule;
import javax.inject.Singleton;
import dagger.Component;
|
package com.nilhcem.devoxxfr.core.dagger;
@Singleton
@Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
public interface AppComponent extends AppGraph {
/**
* An initializer that creates the production graph from an application.
*/
final class Initializer {
private Initializer() {
throw new UnsupportedOperationException();
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
// @Module
// public final class ApiModule {
//
// @Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
// return ApiEndpoint.get(context);
// }
//
// @Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
// return new Retrofit.Builder()
// .client(client)
// .baseUrl(endpoint.url)
// .addConverterFactory(MoshiConverterFactory.create(moshi))
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .build();
// }
//
// @Provides @Singleton DevoxxService provideDevoxxService(Retrofit retrofit) {
// return retrofit.create(DevoxxService.class);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
// @Module
// public final class AppModule {
//
// private final DevoxxApp app;
//
// public AppModule(DevoxxApp app) {
// this.app = app;
// }
//
// @Provides @Singleton Application provideApplication() {
// return app;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
// @Module(includes = OkHttpModule.class)
// public final class DataModule {
//
// private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
//
// @Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
// return PreferenceManager.getDefaultSharedPreferences(app);
// }
//
// @Provides @Singleton Moshi provideMoshi(LocalDateTimeAdapter localDateTimeAdapter) {
// return new Moshi.Builder()
// .add(localDateTimeAdapter)
// .build();
// }
//
// @Provides @Singleton OkHttpClient.Builder provideOkHttpClientBuilder(Application app) {
// File cacheDir = new File(app.getCacheDir(), "http");
// Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE);
// return new OkHttpClient.Builder().cache(cache);
// }
//
// @Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
// return new Picasso.Builder(app)
// .downloader(new OkHttp3Downloader(client))
// .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
// .build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
// @Module
// public class DatabaseModule {
//
// static final String TAG = "database";
//
// @Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
// return new DbOpenHelper(application);
// }
//
// @Provides @Singleton SqlBrite provideSqlBrite() {
// return SqlBrite.create(Timber.tag(TAG)::v);
// }
//
// @Provides @Singleton BriteDatabase provideBriteDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
// return sqlBrite.wrapDatabaseHelper(helper, Schedulers.immediate());
// }
// }
// Path: app/src/production/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.core.dagger.module.ApiModule;
import com.nilhcem.devoxxfr.core.dagger.module.AppModule;
import com.nilhcem.devoxxfr.core.dagger.module.DataModule;
import com.nilhcem.devoxxfr.core.dagger.module.DatabaseModule;
import javax.inject.Singleton;
import dagger.Component;
package com.nilhcem.devoxxfr.core.dagger;
@Singleton
@Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
public interface AppComponent extends AppGraph {
/**
* An initializer that creates the production graph from an application.
*/
final class Initializer {
private Initializer() {
throw new UnsupportedOperationException();
}
|
public static AppComponent init(DevoxxApp app) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
|
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import javax.inject.Inject;
import hugo.weaving.DebugLog;
|
package com.nilhcem.devoxxfr.receiver;
@DebugLog
public class BootReceiver extends BroadcastReceiver {
public static void enable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
public static void disable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
}
private static void setActivationState(Context context, int state) {
ComponentName componentName = new ComponentName(context, BootReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import javax.inject.Inject;
import hugo.weaving.DebugLog;
package com.nilhcem.devoxxfr.receiver;
@DebugLog
public class BootReceiver extends BroadcastReceiver {
public static void enable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
public static void disable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
}
private static void setActivationState(Context context, int state) {
ComponentName componentName = new ComponentName(context, BootReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
}
|
@Inject SessionsReminder sessionsReminder;
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
|
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import javax.inject.Inject;
import hugo.weaving.DebugLog;
|
package com.nilhcem.devoxxfr.receiver;
@DebugLog
public class BootReceiver extends BroadcastReceiver {
public static void enable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
public static void disable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
}
private static void setActivationState(Context context, int state) {
ComponentName componentName = new ComponentName(context, BootReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
}
@Inject SessionsReminder sessionsReminder;
public BootReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/receiver/BootReceiver.java
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.receiver.reminder.SessionsReminder;
import javax.inject.Inject;
import hugo.weaving.DebugLog;
package com.nilhcem.devoxxfr.receiver;
@DebugLog
public class BootReceiver extends BroadcastReceiver {
public static void enable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
}
public static void disable(Context context) {
setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
}
private static void setActivationState(Context context, int state) {
ComponentName componentName = new ComponentName(context, BootReceiver.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
}
@Inject SessionsReminder sessionsReminder;
public BootReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
|
DevoxxApp.get(context).component().inject(this);
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
// @ToString
// public enum ApiEndpoint {
//
// PROD(BuildConfig.API_ENDPOINT),
// MOCK(BuildConfig.MOCK_ENDPOINT),
// CUSTOM(null);
//
// private static final String PREFS_NAME = "api_endpoint";
// private static final String PREFS_KEY_NAME = "name";
// private static final String PREFS_KEY_URL = "url";
//
// public String url;
//
// ApiEndpoint(String url) {
// this.url = url;
// }
//
// public static ApiEndpoint get(Context context) {
// SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
// String prefsName = prefs.getString(PREFS_KEY_NAME, null);
// if (prefsName != null) {
// ApiEndpoint endpoint = valueOf(prefsName);
// if (endpoint == CUSTOM) {
// endpoint.url = prefs.getString(PREFS_KEY_URL, null);
// }
// return endpoint;
// }
// return PROD;
// }
//
// public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
// Preconditions.checkArgument(endpoint != CUSTOM);
// persistEndpoint(context, endpoint, null);
// }
//
// public static void persist(Context context, @NonNull String url) {
// persistEndpoint(context, CUSTOM, url);
// }
//
// @SuppressLint("CommitPrefEdits")
// private static void persistEndpoint(Context context, @NonNull ApiEndpoint endpoint, @Nullable String url) {
// SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
// editor.putString(PREFS_KEY_NAME, endpoint.name());
//
// if (url == null) {
// editor.remove(PREFS_KEY_URL);
// } else {
// editor.putString(PREFS_KEY_URL, url);
// }
//
// editor.commit();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
// public interface DevoxxService {
//
// @GET("sessions")
// Observable<List<Session>> loadSessions();
//
// @GET("speakers")
// Observable<List<Speaker>> loadSpeakers();
// }
|
import android.app.Application;
import com.nilhcem.devoxxfr.data.network.ApiEndpoint;
import com.nilhcem.devoxxfr.data.network.DevoxxService;
import com.squareup.moshi.Moshi;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.moshi.MoshiConverterFactory;
|
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class ApiModule {
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
// @ToString
// public enum ApiEndpoint {
//
// PROD(BuildConfig.API_ENDPOINT),
// MOCK(BuildConfig.MOCK_ENDPOINT),
// CUSTOM(null);
//
// private static final String PREFS_NAME = "api_endpoint";
// private static final String PREFS_KEY_NAME = "name";
// private static final String PREFS_KEY_URL = "url";
//
// public String url;
//
// ApiEndpoint(String url) {
// this.url = url;
// }
//
// public static ApiEndpoint get(Context context) {
// SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
// String prefsName = prefs.getString(PREFS_KEY_NAME, null);
// if (prefsName != null) {
// ApiEndpoint endpoint = valueOf(prefsName);
// if (endpoint == CUSTOM) {
// endpoint.url = prefs.getString(PREFS_KEY_URL, null);
// }
// return endpoint;
// }
// return PROD;
// }
//
// public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
// Preconditions.checkArgument(endpoint != CUSTOM);
// persistEndpoint(context, endpoint, null);
// }
//
// public static void persist(Context context, @NonNull String url) {
// persistEndpoint(context, CUSTOM, url);
// }
//
// @SuppressLint("CommitPrefEdits")
// private static void persistEndpoint(Context context, @NonNull ApiEndpoint endpoint, @Nullable String url) {
// SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
// editor.putString(PREFS_KEY_NAME, endpoint.name());
//
// if (url == null) {
// editor.remove(PREFS_KEY_URL);
// } else {
// editor.putString(PREFS_KEY_URL, url);
// }
//
// editor.commit();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
// public interface DevoxxService {
//
// @GET("sessions")
// Observable<List<Session>> loadSessions();
//
// @GET("speakers")
// Observable<List<Speaker>> loadSpeakers();
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
import android.app.Application;
import com.nilhcem.devoxxfr.data.network.ApiEndpoint;
import com.nilhcem.devoxxfr.data.network.DevoxxService;
import com.squareup.moshi.Moshi;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.moshi.MoshiConverterFactory;
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class ApiModule {
|
@Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
|
Nilhcem/devoxxfr-2016
|
app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
// @ToString
// public enum ApiEndpoint {
//
// PROD(BuildConfig.API_ENDPOINT),
// MOCK(BuildConfig.MOCK_ENDPOINT),
// CUSTOM(null);
//
// private static final String PREFS_NAME = "api_endpoint";
// private static final String PREFS_KEY_NAME = "name";
// private static final String PREFS_KEY_URL = "url";
//
// public String url;
//
// ApiEndpoint(String url) {
// this.url = url;
// }
//
// public static ApiEndpoint get(Context context) {
// SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
// String prefsName = prefs.getString(PREFS_KEY_NAME, null);
// if (prefsName != null) {
// ApiEndpoint endpoint = valueOf(prefsName);
// if (endpoint == CUSTOM) {
// endpoint.url = prefs.getString(PREFS_KEY_URL, null);
// }
// return endpoint;
// }
// return PROD;
// }
//
// public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
// Preconditions.checkArgument(endpoint != CUSTOM);
// persistEndpoint(context, endpoint, null);
// }
//
// public static void persist(Context context, @NonNull String url) {
// persistEndpoint(context, CUSTOM, url);
// }
//
// @SuppressLint("CommitPrefEdits")
// private static void persistEndpoint(Context context, @NonNull ApiEndpoint endpoint, @Nullable String url) {
// SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
// editor.putString(PREFS_KEY_NAME, endpoint.name());
//
// if (url == null) {
// editor.remove(PREFS_KEY_URL);
// } else {
// editor.putString(PREFS_KEY_URL, url);
// }
//
// editor.commit();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
// public interface DevoxxService {
//
// @GET("sessions")
// Observable<List<Session>> loadSessions();
//
// @GET("speakers")
// Observable<List<Speaker>> loadSpeakers();
// }
|
import android.app.Application;
import com.nilhcem.devoxxfr.data.network.ApiEndpoint;
import com.nilhcem.devoxxfr.data.network.DevoxxService;
import com.squareup.moshi.Moshi;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.moshi.MoshiConverterFactory;
|
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class ApiModule {
@Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
return ApiEndpoint.get(context);
}
@Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
return new Retrofit.Builder()
.client(client)
.baseUrl(endpoint.url)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
}
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/data/network/ApiEndpoint.java
// @ToString
// public enum ApiEndpoint {
//
// PROD(BuildConfig.API_ENDPOINT),
// MOCK(BuildConfig.MOCK_ENDPOINT),
// CUSTOM(null);
//
// private static final String PREFS_NAME = "api_endpoint";
// private static final String PREFS_KEY_NAME = "name";
// private static final String PREFS_KEY_URL = "url";
//
// public String url;
//
// ApiEndpoint(String url) {
// this.url = url;
// }
//
// public static ApiEndpoint get(Context context) {
// SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
// String prefsName = prefs.getString(PREFS_KEY_NAME, null);
// if (prefsName != null) {
// ApiEndpoint endpoint = valueOf(prefsName);
// if (endpoint == CUSTOM) {
// endpoint.url = prefs.getString(PREFS_KEY_URL, null);
// }
// return endpoint;
// }
// return PROD;
// }
//
// public static void persist(Context context, @NonNull ApiEndpoint endpoint) {
// Preconditions.checkArgument(endpoint != CUSTOM);
// persistEndpoint(context, endpoint, null);
// }
//
// public static void persist(Context context, @NonNull String url) {
// persistEndpoint(context, CUSTOM, url);
// }
//
// @SuppressLint("CommitPrefEdits")
// private static void persistEndpoint(Context context, @NonNull ApiEndpoint endpoint, @Nullable String url) {
// SharedPreferences.Editor editor = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
// editor.putString(PREFS_KEY_NAME, endpoint.name());
//
// if (url == null) {
// editor.remove(PREFS_KEY_URL);
// } else {
// editor.putString(PREFS_KEY_URL, url);
// }
//
// editor.commit();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/network/DevoxxService.java
// public interface DevoxxService {
//
// @GET("sessions")
// Observable<List<Session>> loadSessions();
//
// @GET("speakers")
// Observable<List<Speaker>> loadSpeakers();
// }
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
import android.app.Application;
import com.nilhcem.devoxxfr.data.network.ApiEndpoint;
import com.nilhcem.devoxxfr.data.network.DevoxxService;
import com.squareup.moshi.Moshi;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.moshi.MoshiConverterFactory;
package com.nilhcem.devoxxfr.core.dagger.module;
@Module
public final class ApiModule {
@Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
return ApiEndpoint.get(context);
}
@Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
return new Retrofit.Builder()
.client(client)
.baseUrl(endpoint.url)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
}
|
@Provides @Singleton DevoxxService provideDevoxxService(Retrofit retrofit) {
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
// @Module
// public final class ApiModule {
//
// @Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
// return ApiEndpoint.get(context);
// }
//
// @Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
// return new Retrofit.Builder()
// .client(client)
// .baseUrl(endpoint.url)
// .addConverterFactory(MoshiConverterFactory.create(moshi))
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .build();
// }
//
// @Provides @Singleton DevoxxService provideDevoxxService(Retrofit retrofit) {
// return retrofit.create(DevoxxService.class);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
// @Module
// public final class AppModule {
//
// private final DevoxxApp app;
//
// public AppModule(DevoxxApp app) {
// this.app = app;
// }
//
// @Provides @Singleton Application provideApplication() {
// return app;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
// @Module(includes = OkHttpModule.class)
// public final class DataModule {
//
// private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
//
// @Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
// return PreferenceManager.getDefaultSharedPreferences(app);
// }
//
// @Provides @Singleton Moshi provideMoshi(LocalDateTimeAdapter localDateTimeAdapter) {
// return new Moshi.Builder()
// .add(localDateTimeAdapter)
// .build();
// }
//
// @Provides @Singleton OkHttpClient.Builder provideOkHttpClientBuilder(Application app) {
// File cacheDir = new File(app.getCacheDir(), "http");
// Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE);
// return new OkHttpClient.Builder().cache(cache);
// }
//
// @Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
// return new Picasso.Builder(app)
// .downloader(new OkHttp3Downloader(client))
// .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
// .build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
// @Module
// public class DatabaseModule {
//
// static final String TAG = "database";
//
// @Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
// return new DbOpenHelper(application);
// }
//
// @Provides @Singleton SqlBrite provideSqlBrite() {
// return SqlBrite.create(Timber.tag(TAG)::v);
// }
//
// @Provides @Singleton BriteDatabase provideBriteDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
// return sqlBrite.wrapDatabaseHelper(helper, Schedulers.immediate());
// }
// }
|
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.core.dagger.module.ApiModule;
import com.nilhcem.devoxxfr.core.dagger.module.AppModule;
import com.nilhcem.devoxxfr.core.dagger.module.DataModule;
import com.nilhcem.devoxxfr.core.dagger.module.DatabaseModule;
import javax.inject.Singleton;
import dagger.Component;
|
package com.nilhcem.devoxxfr.core.dagger;
@Singleton
@Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
public interface AppComponent extends InternalAppGraph {
/**
* An initializer that creates the internal graph from an application.
*/
final class Initializer {
private Initializer() {
throw new UnsupportedOperationException();
}
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/DevoxxApp.java
// @DebugLog
// public class DevoxxApp extends Application {
//
// private AppComponent component;
//
// public static DevoxxApp get(Context context) {
// return (DevoxxApp) context.getApplicationContext();
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
// AndroidThreeTen.init(this);
// initGraph();
// initLogger();
// }
//
// public AppComponent component() {
// return component;
// }
//
// private void initGraph() {
// component = AppComponent.Initializer.init(this);
// }
//
// private void initLogger() {
// Timber.plant(new Timber.DebugTree());
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/ApiModule.java
// @Module
// public final class ApiModule {
//
// @Provides @Singleton ApiEndpoint provideApiEndpoint(Application context) {
// return ApiEndpoint.get(context);
// }
//
// @Provides @Singleton Retrofit provideRetrofit(OkHttpClient client, Moshi moshi, ApiEndpoint endpoint) {
// return new Retrofit.Builder()
// .client(client)
// .baseUrl(endpoint.url)
// .addConverterFactory(MoshiConverterFactory.create(moshi))
// .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
// .build();
// }
//
// @Provides @Singleton DevoxxService provideDevoxxService(Retrofit retrofit) {
// return retrofit.create(DevoxxService.class);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/AppModule.java
// @Module
// public final class AppModule {
//
// private final DevoxxApp app;
//
// public AppModule(DevoxxApp app) {
// this.app = app;
// }
//
// @Provides @Singleton Application provideApplication() {
// return app;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DataModule.java
// @Module(includes = OkHttpModule.class)
// public final class DataModule {
//
// private static final long DISK_CACHE_SIZE = 31_457_280; // 30MB
//
// @Provides @Singleton SharedPreferences provideSharedPreferences(Application app) {
// return PreferenceManager.getDefaultSharedPreferences(app);
// }
//
// @Provides @Singleton Moshi provideMoshi(LocalDateTimeAdapter localDateTimeAdapter) {
// return new Moshi.Builder()
// .add(localDateTimeAdapter)
// .build();
// }
//
// @Provides @Singleton OkHttpClient.Builder provideOkHttpClientBuilder(Application app) {
// File cacheDir = new File(app.getCacheDir(), "http");
// Cache cache = new Cache(cacheDir, DISK_CACHE_SIZE);
// return new OkHttpClient.Builder().cache(cache);
// }
//
// @Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
// return new Picasso.Builder(app)
// .downloader(new OkHttp3Downloader(client))
// .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
// .build();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/core/dagger/module/DatabaseModule.java
// @Module
// public class DatabaseModule {
//
// static final String TAG = "database";
//
// @Provides @Singleton SQLiteOpenHelper provideSQLiteOpenHelper(Application application) {
// return new DbOpenHelper(application);
// }
//
// @Provides @Singleton SqlBrite provideSqlBrite() {
// return SqlBrite.create(Timber.tag(TAG)::v);
// }
//
// @Provides @Singleton BriteDatabase provideBriteDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
// return sqlBrite.wrapDatabaseHelper(helper, Schedulers.immediate());
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/core/dagger/AppComponent.java
import com.nilhcem.devoxxfr.DevoxxApp;
import com.nilhcem.devoxxfr.core.dagger.module.ApiModule;
import com.nilhcem.devoxxfr.core.dagger.module.AppModule;
import com.nilhcem.devoxxfr.core.dagger.module.DataModule;
import com.nilhcem.devoxxfr.core.dagger.module.DatabaseModule;
import javax.inject.Singleton;
import dagger.Component;
package com.nilhcem.devoxxfr.core.dagger;
@Singleton
@Component(modules = {AppModule.class, ApiModule.class, DataModule.class, DatabaseModule.class})
public interface AppComponent extends InternalAppGraph {
/**
* An initializer that creates the internal graph from an application.
*/
final class Initializer {
private Initializer() {
throw new UnsupportedOperationException();
}
|
public static AppComponent init(DevoxxApp app) {
|
Nilhcem/devoxxfr-2016
|
app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
|
import android.app.Application;
import android.content.Context;
import com.facebook.stetho.DumperPluginsProvider;
import com.facebook.stetho.InspectorModulesProvider;
import com.facebook.stetho.Stetho;
import com.facebook.stetho.dumpapp.DumperPlugin;
import com.facebook.stetho.rhino.JsRuntimeReplFactoryBuilder;
import com.facebook.stetho.timber.StethoTree;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.Scriptable;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import timber.log.Timber;
|
package com.nilhcem.devoxxfr.debug.stetho;
public class StethoInitializer implements DumperPluginsProvider {
private final Context context;
private final AppDumperPlugin appDumper;
|
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/lifecycle/ActivityProvider.java
// @Singleton
// public class ActivityProvider implements Application.ActivityLifecycleCallbacks {
//
// private Activity currentActivity;
//
// @Inject
// public ActivityProvider() {
// }
//
// public void init(Application app) {
// app.registerActivityLifecycleCallbacks(this);
// }
//
// public Activity getCurrentActivity() {
// return currentActivity;
// }
//
// @Override
// public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// }
//
// @Override
// public void onActivityStarted(Activity activity) {
// }
//
// @Override
// public void onActivityResumed(Activity activity) {
// this.currentActivity = activity;
// }
//
// @Override
// public void onActivityPaused(Activity activity) {
// currentActivity = null;
// }
//
// @Override
// public void onActivityStopped(Activity activity) {
// }
//
// @Override
// public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
// }
//
// @Override
// public void onActivityDestroyed(Activity activity) {
// }
// }
// Path: app/src/internal/java/com/nilhcem/devoxxfr/debug/stetho/StethoInitializer.java
import android.app.Application;
import android.content.Context;
import com.facebook.stetho.DumperPluginsProvider;
import com.facebook.stetho.InspectorModulesProvider;
import com.facebook.stetho.Stetho;
import com.facebook.stetho.dumpapp.DumperPlugin;
import com.facebook.stetho.rhino.JsRuntimeReplFactoryBuilder;
import com.facebook.stetho.timber.StethoTree;
import com.nilhcem.devoxxfr.debug.lifecycle.ActivityProvider;
import org.mozilla.javascript.BaseFunction;
import org.mozilla.javascript.Scriptable;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import timber.log.Timber;
package com.nilhcem.devoxxfr.debug.stetho;
public class StethoInitializer implements DumperPluginsProvider {
private final Context context;
private final AppDumperPlugin appDumper;
|
private final ActivityProvider activityProvider;
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/data/app/AppMapperTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Schedule.java
// public class Schedule extends ArrayList<ScheduleDay> implements Parcelable {
//
// public static final Parcelable.Creator<Schedule> CREATOR = new Parcelable.Creator<Schedule>() {
// public Schedule createFromParcel(Parcel source) {
// return new Schedule(source);
// }
//
// public Schedule[] newArray(int size) {
// return new Schedule[size];
// }
// };
//
// public Schedule() {
// }
//
// protected Schedule(Parcel in) {
// addAll(in.createTypedArrayList(ScheduleDay.CREATOR));
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeTypedList(this);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Schedule;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Collections.singletonList;
|
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class AppMapperTest {
private final AppMapper appMapper = new AppMapper();
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Schedule.java
// public class Schedule extends ArrayList<ScheduleDay> implements Parcelable {
//
// public static final Parcelable.Creator<Schedule> CREATOR = new Parcelable.Creator<Schedule>() {
// public Schedule createFromParcel(Parcel source) {
// return new Schedule(source);
// }
//
// public Schedule[] newArray(int size) {
// return new Schedule[size];
// }
// };
//
// public Schedule() {
// }
//
// protected Schedule(Parcel in) {
// addAll(in.createTypedArrayList(ScheduleDay.CREATOR));
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeTypedList(this);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/data/app/model/Speaker.java
// @Value
// public class Speaker implements Parcelable {
//
// public static final Parcelable.Creator<Speaker> CREATOR = new Parcelable.Creator<Speaker>() {
// public Speaker createFromParcel(Parcel source) {
// return new Speaker(source);
// }
//
// public Speaker[] newArray(int size) {
// return new Speaker[size];
// }
// };
//
// int id;
// String name;
// String title;
// String bio;
// String website;
// String twitter;
// String github;
// String photo;
//
// public Speaker(int id, String name, String title, String bio, String website, String twitter, String github, String photo) {
// this.id = id;
// this.name = name;
// this.title = title;
// this.bio = bio;
// this.website = website;
// this.twitter = twitter;
// this.github = github;
// this.photo = photo;
// }
//
// protected Speaker(Parcel in) {
// id = in.readInt();
// name = in.readString();
// title = in.readString();
// bio = in.readString();
// website = in.readString();
// twitter = in.readString();
// github = in.readString();
// photo = in.readString();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(name);
// dest.writeString(title);
// dest.writeString(bio);
// dest.writeString(website);
// dest.writeString(twitter);
// dest.writeString(github);
// dest.writeString(photo);
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/data/app/AppMapperTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.data.app.model.Schedule;
import com.nilhcem.devoxxfr.data.app.model.Session;
import com.nilhcem.devoxxfr.data.app.model.Speaker;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Collections.singletonList;
package com.nilhcem.devoxxfr.data.app;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class AppMapperTest {
private final AppMapper appMapper = new AppMapper();
|
private final Speaker speaker1 = new Speaker(10, "Gautier", null, null, null, null, null, null);
|
Nilhcem/devoxxfr-2016
|
app/src/test/java/com/nilhcem/devoxxfr/ui/drawer/DrawerPresenterTest.java
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/pager/SchedulePagerFragment.java
// @FragmentWithArgs
// public class SchedulePagerFragment extends BaseFragment<SchedulePagerPresenter> implements SchedulePagerView {
//
// @Arg boolean allSessions;
//
// @Inject DataProvider dataProvider;
//
// @Bind(R.id.schedule_loading) ProgressBar loading;
// @Bind(R.id.schedule_viewpager) ViewPager viewPager;
//
// private Snackbar errorSnackbar;
//
// @Override
// protected SchedulePagerPresenter newPresenter() {
// return new SchedulePagerPresenter(this, dataProvider);
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// DevoxxApp.get(getContext()).component().inject(this);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// return inflater.inflate(R.layout.schedule_pager, container, false);
// }
//
// @Override
// public void onDestroyView() {
// if (errorSnackbar != null) {
// errorSnackbar.dismiss();
// }
// super.onDestroyView();
// }
//
// @Override
// public void displaySchedule(Schedule schedule) {
// viewPager.setAdapter(new SchedulePagerAdapter(getContext(), getChildFragmentManager(), schedule, allSessions));
// if (schedule.size() > 1) {
// ((DrawerActivity) getActivity()).setupTabLayoutWithViewPager(viewPager);
// }
//
// loading.setVisibility(View.GONE);
// viewPager.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void displayLoadingError() {
// loading.setVisibility(View.GONE);
// errorSnackbar = Snackbar.make(loading, R.string.connection_error, Snackbar.LENGTH_INDEFINITE)
// .setAction(R.string.connection_error_retry, v -> presenter.reloadData());
// errorSnackbar.show();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/speakers/list/SpeakersListFragment.java
// public class SpeakersListFragment extends BaseFragment<SpeakersListPresenter> implements SpeakersListView {
//
// @Inject Picasso picasso;
// @Inject DataProvider dataProvider;
//
// @Bind(R.id.speakers_list_loading) ProgressBar loading;
// @Bind(R.id.speakers_list_recyclerview) RecyclerView recyclerView;
//
// private Snackbar errorSnackbar;
// private SpeakersListAdapter adapter;
//
// @Override
// protected SpeakersListPresenter newPresenter() {
// return new SpeakersListPresenter(this, dataProvider);
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// DevoxxApp.get(getContext()).component().inject(this);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// return inflater.inflate(R.layout.speakers_list, container, false);
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// adapter = new SpeakersListAdapter(picasso, this);
// recyclerView.addItemDecoration(new MarginDecoration(getContext()));
// recyclerView.setHasFixedSize(true);
// recyclerView.setAdapter(adapter);
// }
//
// @Override
// public void onDestroyView() {
// if (errorSnackbar != null) {
// errorSnackbar.dismiss();
// }
// super.onDestroyView();
// }
//
// @Override
// public void displaySpeakers(List<Speaker> speakers) {
// adapter.setSpeakers(speakers);
// loading.setVisibility(View.GONE);
// recyclerView.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void displayLoadingError() {
// loading.setVisibility(View.GONE);
// errorSnackbar = Snackbar.make(loading, R.string.connection_error, Snackbar.LENGTH_INDEFINITE)
// .setAction(R.string.connection_error_retry, v -> presenter.reloadData());
// errorSnackbar.show();
// }
//
// @Override
// public void showSpeakerDetails(Speaker speaker) {
// SpeakerDetailsDialogFragment.show(speaker, getFragmentManager());
// }
// }
|
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.ui.schedule.pager.SchedulePagerFragment;
import com.nilhcem.devoxxfr.ui.speakers.list.SpeakersListFragment;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
|
package com.nilhcem.devoxxfr.ui.drawer;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DrawerPresenterTest {
@Mock DrawerActivityView view;
private DrawerPresenter presenter;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
presenter = new DrawerPresenter(view);
}
@Test
public void should_automatically_select_my_schedule_when_starting_the_app() {
// When
presenter.onPostCreate(null);
// Then
|
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/schedule/pager/SchedulePagerFragment.java
// @FragmentWithArgs
// public class SchedulePagerFragment extends BaseFragment<SchedulePagerPresenter> implements SchedulePagerView {
//
// @Arg boolean allSessions;
//
// @Inject DataProvider dataProvider;
//
// @Bind(R.id.schedule_loading) ProgressBar loading;
// @Bind(R.id.schedule_viewpager) ViewPager viewPager;
//
// private Snackbar errorSnackbar;
//
// @Override
// protected SchedulePagerPresenter newPresenter() {
// return new SchedulePagerPresenter(this, dataProvider);
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// DevoxxApp.get(getContext()).component().inject(this);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// return inflater.inflate(R.layout.schedule_pager, container, false);
// }
//
// @Override
// public void onDestroyView() {
// if (errorSnackbar != null) {
// errorSnackbar.dismiss();
// }
// super.onDestroyView();
// }
//
// @Override
// public void displaySchedule(Schedule schedule) {
// viewPager.setAdapter(new SchedulePagerAdapter(getContext(), getChildFragmentManager(), schedule, allSessions));
// if (schedule.size() > 1) {
// ((DrawerActivity) getActivity()).setupTabLayoutWithViewPager(viewPager);
// }
//
// loading.setVisibility(View.GONE);
// viewPager.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void displayLoadingError() {
// loading.setVisibility(View.GONE);
// errorSnackbar = Snackbar.make(loading, R.string.connection_error, Snackbar.LENGTH_INDEFINITE)
// .setAction(R.string.connection_error_retry, v -> presenter.reloadData());
// errorSnackbar.show();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devoxxfr/ui/speakers/list/SpeakersListFragment.java
// public class SpeakersListFragment extends BaseFragment<SpeakersListPresenter> implements SpeakersListView {
//
// @Inject Picasso picasso;
// @Inject DataProvider dataProvider;
//
// @Bind(R.id.speakers_list_loading) ProgressBar loading;
// @Bind(R.id.speakers_list_recyclerview) RecyclerView recyclerView;
//
// private Snackbar errorSnackbar;
// private SpeakersListAdapter adapter;
//
// @Override
// protected SpeakersListPresenter newPresenter() {
// return new SpeakersListPresenter(this, dataProvider);
// }
//
// @Override
// public void onCreate(@Nullable Bundle savedInstanceState) {
// DevoxxApp.get(getContext()).component().inject(this);
// super.onCreate(savedInstanceState);
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// return inflater.inflate(R.layout.speakers_list, container, false);
// }
//
// @Override
// public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
// super.onViewCreated(view, savedInstanceState);
// adapter = new SpeakersListAdapter(picasso, this);
// recyclerView.addItemDecoration(new MarginDecoration(getContext()));
// recyclerView.setHasFixedSize(true);
// recyclerView.setAdapter(adapter);
// }
//
// @Override
// public void onDestroyView() {
// if (errorSnackbar != null) {
// errorSnackbar.dismiss();
// }
// super.onDestroyView();
// }
//
// @Override
// public void displaySpeakers(List<Speaker> speakers) {
// adapter.setSpeakers(speakers);
// loading.setVisibility(View.GONE);
// recyclerView.setVisibility(View.VISIBLE);
// }
//
// @Override
// public void displayLoadingError() {
// loading.setVisibility(View.GONE);
// errorSnackbar = Snackbar.make(loading, R.string.connection_error, Snackbar.LENGTH_INDEFINITE)
// .setAction(R.string.connection_error_retry, v -> presenter.reloadData());
// errorSnackbar.show();
// }
//
// @Override
// public void showSpeakerDetails(Speaker speaker) {
// SpeakerDetailsDialogFragment.show(speaker, getFragmentManager());
// }
// }
// Path: app/src/test/java/com/nilhcem/devoxxfr/ui/drawer/DrawerPresenterTest.java
import android.os.Build;
import com.nilhcem.devoxxfr.BuildConfig;
import com.nilhcem.devoxxfr.R;
import com.nilhcem.devoxxfr.ui.schedule.pager.SchedulePagerFragment;
import com.nilhcem.devoxxfr.ui.speakers.list.SpeakersListFragment;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
package com.nilhcem.devoxxfr.ui.drawer;
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class DrawerPresenterTest {
@Mock DrawerActivityView view;
private DrawerPresenter presenter;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
presenter = new DrawerPresenter(view);
}
@Test
public void should_automatically_select_my_schedule_when_starting_the_app() {
// When
presenter.onPostCreate(null);
// Then
|
verify(view).showFragment(any(SchedulePagerFragment.class));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.