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
|
|---|---|---|---|---|---|---|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Skeleton.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.kafka.*;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentTopology;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
import static com.google.common.base.Preconditions.checkArgument;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Skeleton {
private static final Logger log = LoggerFactory.getLogger(Skeleton.class);
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
topology
.newStream("tweets", spout)
.each(new Fields("str"), new Print())
;
topology
.newDRPCStream("ping");
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/Skeleton.java
import backtype.storm.Config;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.kafka.*;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentTopology;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
import static com.google.common.base.Preconditions.checkArgument;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Skeleton {
private static final Logger log = LoggerFactory.getLogger(Skeleton.class);
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
topology
.newStream("tweets", spout)
.each(new Fields("str"), new Print())
;
topology
.newDRPCStream("ping");
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
TransactionalTridentKafkaSpout kafkaSpout = TestUtils.testTweetSpout(hosts);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagFollowerCountGrouping.java
|
// Path: src/main/java/tutorial/storm/trident/state/HazelCastStateFactory.java
// public class HazelCastStateFactory<T> implements StateFactory {
//
//
// @Override
// public MapState<T> makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// IBackingMap im = new HazelCastState<T>(new HazelCastHandler<TransactionalValue<T>>());
// return TransactionalMap.build(im);
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.state.HazelCastStateFactory;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagFollowerCountGrouping {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
.each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName"))
.parallelismHint(3)
.groupBy(new Fields("followerClass", "contentName"))
|
// Path: src/main/java/tutorial/storm/trident/state/HazelCastStateFactory.java
// public class HazelCastStateFactory<T> implements StateFactory {
//
//
// @Override
// public MapState<T> makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// IBackingMap im = new HazelCastState<T>(new HazelCastHandler<TransactionalValue<T>>());
// return TransactionalMap.build(im);
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagFollowerCountGrouping.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.state.HazelCastStateFactory;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagFollowerCountGrouping {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
.each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName"))
.parallelismHint(3)
.groupBy(new Fields("followerClass", "contentName"))
|
.persistentAggregate(new HazelCastStateFactory(), new Count(), new Fields("count"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagFollowerCountGrouping.java
|
// Path: src/main/java/tutorial/storm/trident/state/HazelCastStateFactory.java
// public class HazelCastStateFactory<T> implements StateFactory {
//
//
// @Override
// public MapState<T> makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// IBackingMap im = new HazelCastState<T>(new HazelCastHandler<TransactionalValue<T>>());
// return TransactionalMap.build(im);
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.state.HazelCastStateFactory;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagFollowerCountGrouping {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
.each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName"))
.parallelismHint(3)
.groupBy(new Fields("followerClass", "contentName"))
.persistentAggregate(new HazelCastStateFactory(), new Count(), new Fields("count"))
.parallelismHint(3)
;
topology
.newDRPCStream("hashtag_count")
.each(new Constants<String>("< 100", "< 10K", "< 100K", ">= 100K"), new Fields("followerClass"))
.stateQuery(count, new Fields("followerClass", "args"), new MapGet(), new Fields("count"))
;
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setNumWorkers(6);
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
// Path: src/main/java/tutorial/storm/trident/state/HazelCastStateFactory.java
// public class HazelCastStateFactory<T> implements StateFactory {
//
//
// @Override
// public MapState<T> makeState(Map conf, IMetricsContext metrics, int partitionIndex, int numPartitions) {
// IBackingMap im = new HazelCastState<T>(new HazelCastHandler<TransactionalValue<T>>());
// return TransactionalMap.build(im);
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagFollowerCountGrouping.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.state.HazelCastStateFactory;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagFollowerCountGrouping {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
.each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName"))
.parallelismHint(3)
.groupBy(new Fields("followerClass", "contentName"))
.persistentAggregate(new HazelCastStateFactory(), new Count(), new Fields("count"))
.parallelismHint(3)
;
topology
.newDRPCStream("hashtag_count")
.each(new Constants<String>("< 100", "< 10K", "< 100K", ">= 100K"), new Fields("followerClass"))
.stateQuery(count, new Fields("followerClass", "args"), new MapGet(), new Fields("count"))
;
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
conf.setNumWorkers(6);
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
TransactionalTridentKafkaSpout kafkaSpout = TestUtils.testTweetSpout(hosts);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/JoinExample.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.Stream;
import storm.trident.TridentTopology;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* This is a really simple example on how do joins between streams with Trident.
*
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class JoinExample {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout)
throws IOException {
TridentTopology topology = new TridentTopology();
/**
* First, grab the tweets stream. We're going to use it in two different places
* and then, we'll going to join them.
*
*/
Stream contents = topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"));
/**
* Now, let's select and project only hashtags for each tweet.
* This stream is basically a list of couples (tweetId, hashtag).
*
*/
Stream hashtags = contents
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("content"), new TweetIdExtractor(), new Fields("tweetId"))
.each(new Fields("content"), new GetContentName(), new Fields("hashtag"))
.project(new Fields("hashtag", "tweetId"));
//.each(new Fields("content", "tweetId"), new DebugFilter());
/**
* And let's do the same for urls, obtaining a stream of couples
* like (tweetId, url).
*
*/
Stream urls = contents
.each(new Fields("content"), new OnlyUrls())
.each(new Fields("content"), new TweetIdExtractor(), new Fields("tweetId"))
.each(new Fields("content"), new GetContentName(), new Fields("url"))
.project(new Fields("url", "tweetId"));
//.each(new Fields("content", "tweetId"), new DebugFilter());
/**
* Now is time to join on the tweetId to get a stream of triples (tweetId, hashtag, url).
*
*/
topology.join(hashtags, new Fields("tweetId"), urls, new Fields("tweetId"), new Fields("tweetId", "hashtag", "url"))
.each(new Fields("tweetId", "hashtag", "url"), new Print());
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/JoinExample.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.Stream;
import storm.trident.TridentTopology;
import tutorial.storm.trident.operations.*;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* This is a really simple example on how do joins between streams with Trident.
*
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class JoinExample {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout)
throws IOException {
TridentTopology topology = new TridentTopology();
/**
* First, grab the tweets stream. We're going to use it in two different places
* and then, we'll going to join them.
*
*/
Stream contents = topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"));
/**
* Now, let's select and project only hashtags for each tweet.
* This stream is basically a list of couples (tweetId, hashtag).
*
*/
Stream hashtags = contents
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("content"), new TweetIdExtractor(), new Fields("tweetId"))
.each(new Fields("content"), new GetContentName(), new Fields("hashtag"))
.project(new Fields("hashtag", "tweetId"));
//.each(new Fields("content", "tweetId"), new DebugFilter());
/**
* And let's do the same for urls, obtaining a stream of couples
* like (tweetId, url).
*
*/
Stream urls = contents
.each(new Fields("content"), new OnlyUrls())
.each(new Fields("content"), new TweetIdExtractor(), new Fields("tweetId"))
.each(new Fields("content"), new GetContentName(), new Fields("url"))
.project(new Fields("url", "tweetId"));
//.each(new Fields("content", "tweetId"), new DebugFilter());
/**
* Now is time to join on the tweetId to get a stream of triples (tweetId, hashtag, url).
*
*/
topology.join(hashtags, new Fields("tweetId"), urls, new Fields("tweetId"), new Fields("tweetId", "hashtag", "url"))
.each(new Fields("tweetId", "hashtag", "url"), new Print());
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
TransactionalTridentKafkaSpout kafkaSpout = TestUtils.testTweetSpout(hosts);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/ClusterTestTopology.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
|
import backtype.storm.Config;
import backtype.storm.StormSubmitter;
import backtype.storm.tuple.Fields;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.MapGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
|
package tutorial.storm.trident;
/**
* Silly test topology to test the cluster
*
* @author Enno Shioji (eshioji@gmail.com)
*/
public class ClusterTestTopology {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// Submits the topology
String topologyName = args[0];
conf.setNumWorkers(8); // Our Vagrant environment has 8 workers
|
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
// Path: src/main/java/tutorial/storm/trident/ClusterTestTopology.java
import backtype.storm.Config;
import backtype.storm.StormSubmitter;
import backtype.storm.tuple.Fields;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.MapGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
package tutorial.storm.trident;
/**
* Silly test topology to test the cluster
*
* @author Enno Shioji (eshioji@gmail.com)
*/
public class ClusterTestTopology {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// Submits the topology
String topologyName = args[0];
conf.setNumWorkers(8); // Our Vagrant environment has 8 workers
|
FakeTweetsBatchSpout fakeTweets = new FakeTweetsBatchSpout(10);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Part04_BasicStateAndDRPC.java
|
// Path: src/main/java/tutorial/storm/trident/operations/Split.java
// public class Split extends BaseFunction {
// private final String on;
// private Splitter splitter;
//
// public Split(String on) {
// this.on = on;
// }
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(splitter==null){
// splitter = Splitter.on(on);
// }
//
// String string = tuple.getString(0);
// for (String spilt : splitter.split(string)) {
// collector.emit(new Values(spilt));
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetGenerator.java
// public class FakeTweetGenerator {
// private static final Logger log = LoggerFactory.getLogger(FakeTweetGenerator.class);
// public final static String[] ACTORS = {"stefan", "dave", "pere", "nathan", "doug", "ted", "mary", "rose"};
// public final static String[] LOCATIONS = {"Spain", "USA", "Spain", "USA", "USA", "USA", "UK", "France"};
// public final static String[] SUBJECTS = {"berlin", "justinbieber", "hadoop", "life", "bigdata"};
//
// private double[] activityDistribution;
// private double[][] subjectInterestDistribution;
// private Random randomGenerator;
// private String[] sentences;
//
// private long tweetId = 0;
//
// public FakeTweetGenerator(){
// this.randomGenerator = new Random();
// // read a resource with 500 sample english sentences
// try {
// sentences = (String[]) IOUtils.readLines(
// ClassLoader.getSystemClassLoader().getResourceAsStream("500_sentences_en.txt")).toArray(new String[0]);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// // will define which actors are more proactive than the others
// this.activityDistribution = getProbabilityDistribution(ACTORS.length, randomGenerator);
// // will define what subjects each of the actors are most interested in
// this.subjectInterestDistribution = new double[ACTORS.length][];
// for (int i = 0; i < ACTORS.length; i++) {
// this.subjectInterestDistribution[i] = getProbabilityDistribution(SUBJECTS.length, randomGenerator);
// }
//
// }
// // --- Helper methods --- //
// // SimpleDateFormat is not thread safe!
// private SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss aa");
//
// public Values getNextTweet() {
// int actorIndex = randomIndex(activityDistribution, randomGenerator);
// String author = ACTORS[actorIndex];
// String text = sentences[randomGenerator.nextInt(sentences.length)].trim() + " #"
// + SUBJECTS[randomIndex(subjectInterestDistribution[actorIndex], randomGenerator)];
// return new Values(++tweetId + "", text, author, LOCATIONS[actorIndex], DATE_FORMAT.format(System
// .currentTimeMillis()));
// }
//
// public List<Values> getNextTweetTuples(String actor) {
// int actorIndex = randomIndex(activityDistribution, randomGenerator);
// String text = sentences[randomGenerator.nextInt(sentences.length)].trim() + " #"
// + SUBJECTS[randomIndex(subjectInterestDistribution[actorIndex], randomGenerator)];
// return ImmutableList.of(new Values(++tweetId + "", text, actor, LOCATIONS[actorIndex], DATE_FORMAT.format(System
// .currentTimeMillis())));
// }
//
// /**
// * Code snippet: http://stackoverflow.com/questions/2171074/generating-a-probability-distribution Returns an array of
// * size "n" with probabilities between 0 and 1 such that sum(array) = 1.
// */
// private static double[] getProbabilityDistribution(int n, Random randomGenerator) {
// double a[] = new double[n];
// double s = 0.0d;
// for (int i = 0; i < n; i++) {
// a[i] = 1.0d - randomGenerator.nextDouble();
// a[i] = -1 * Math.log(a[i]);
// s += a[i];
// }
// for (int i = 0; i < n; i++) {
// a[i] /= s;
// }
// return a;
// }
//
// private static int randomIndex(double[] distribution, Random randomGenerator) {
// double rnd = randomGenerator.nextDouble();
// double accum = 0;
// int index = 0;
// for (; index < distribution.length && accum < rnd; index++, accum += distribution[index - 1])
// ;
// return index - 1;
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FilterNull;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.Split;
import tutorial.storm.trident.testutil.FakeTweetGenerator;
import java.io.IOException;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part04_BasicStateAndDRPC {
private static final Logger log = LoggerFactory.getLogger(Part04_BasicStateAndDRPC.class);
public static void main(String[] args) throws Exception{
|
// Path: src/main/java/tutorial/storm/trident/operations/Split.java
// public class Split extends BaseFunction {
// private final String on;
// private Splitter splitter;
//
// public Split(String on) {
// this.on = on;
// }
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(splitter==null){
// splitter = Splitter.on(on);
// }
//
// String string = tuple.getString(0);
// for (String spilt : splitter.split(string)) {
// collector.emit(new Values(spilt));
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetGenerator.java
// public class FakeTweetGenerator {
// private static final Logger log = LoggerFactory.getLogger(FakeTweetGenerator.class);
// public final static String[] ACTORS = {"stefan", "dave", "pere", "nathan", "doug", "ted", "mary", "rose"};
// public final static String[] LOCATIONS = {"Spain", "USA", "Spain", "USA", "USA", "USA", "UK", "France"};
// public final static String[] SUBJECTS = {"berlin", "justinbieber", "hadoop", "life", "bigdata"};
//
// private double[] activityDistribution;
// private double[][] subjectInterestDistribution;
// private Random randomGenerator;
// private String[] sentences;
//
// private long tweetId = 0;
//
// public FakeTweetGenerator(){
// this.randomGenerator = new Random();
// // read a resource with 500 sample english sentences
// try {
// sentences = (String[]) IOUtils.readLines(
// ClassLoader.getSystemClassLoader().getResourceAsStream("500_sentences_en.txt")).toArray(new String[0]);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// // will define which actors are more proactive than the others
// this.activityDistribution = getProbabilityDistribution(ACTORS.length, randomGenerator);
// // will define what subjects each of the actors are most interested in
// this.subjectInterestDistribution = new double[ACTORS.length][];
// for (int i = 0; i < ACTORS.length; i++) {
// this.subjectInterestDistribution[i] = getProbabilityDistribution(SUBJECTS.length, randomGenerator);
// }
//
// }
// // --- Helper methods --- //
// // SimpleDateFormat is not thread safe!
// private SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss aa");
//
// public Values getNextTweet() {
// int actorIndex = randomIndex(activityDistribution, randomGenerator);
// String author = ACTORS[actorIndex];
// String text = sentences[randomGenerator.nextInt(sentences.length)].trim() + " #"
// + SUBJECTS[randomIndex(subjectInterestDistribution[actorIndex], randomGenerator)];
// return new Values(++tweetId + "", text, author, LOCATIONS[actorIndex], DATE_FORMAT.format(System
// .currentTimeMillis()));
// }
//
// public List<Values> getNextTweetTuples(String actor) {
// int actorIndex = randomIndex(activityDistribution, randomGenerator);
// String text = sentences[randomGenerator.nextInt(sentences.length)].trim() + " #"
// + SUBJECTS[randomIndex(subjectInterestDistribution[actorIndex], randomGenerator)];
// return ImmutableList.of(new Values(++tweetId + "", text, actor, LOCATIONS[actorIndex], DATE_FORMAT.format(System
// .currentTimeMillis())));
// }
//
// /**
// * Code snippet: http://stackoverflow.com/questions/2171074/generating-a-probability-distribution Returns an array of
// * size "n" with probabilities between 0 and 1 such that sum(array) = 1.
// */
// private static double[] getProbabilityDistribution(int n, Random randomGenerator) {
// double a[] = new double[n];
// double s = 0.0d;
// for (int i = 0; i < n; i++) {
// a[i] = 1.0d - randomGenerator.nextDouble();
// a[i] = -1 * Math.log(a[i]);
// s += a[i];
// }
// for (int i = 0; i < n; i++) {
// a[i] /= s;
// }
// return a;
// }
//
// private static int randomIndex(double[] distribution, Random randomGenerator) {
// double rnd = randomGenerator.nextDouble();
// double accum = 0;
// int index = 0;
// for (; index < distribution.length && accum < rnd; index++, accum += distribution[index - 1])
// ;
// return index - 1;
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/Part04_BasicStateAndDRPC.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import com.google.common.collect.ImmutableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FilterNull;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.Split;
import tutorial.storm.trident.testutil.FakeTweetGenerator;
import java.io.IOException;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part04_BasicStateAndDRPC {
private static final Logger log = LoggerFactory.getLogger(Part04_BasicStateAndDRPC.class);
public static void main(String[] args) throws Exception{
|
FakeTweetGenerator fakeTweets = new FakeTweetGenerator();
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
|
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
|
.each(new Fields("content"), new OnlyHashtags())
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
|
.each(new Fields("status"), new OnlyGeo())
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("status"), new OnlyGeo())
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("status"), new OnlyGeo())
|
.each(new Fields("status", "content"), new ExtractLocation(), new Fields("country", "contentName"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("status"), new OnlyGeo())
.each(new Fields("status", "content"), new ExtractLocation(), new Fields("country", "contentName"))
.groupBy(new Fields("country", "contentName"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
;
topology
.newDRPCStream("location_hashtag_count")
.stateQuery(count, new TupleCollectionGet(), new Fields("country", "contentName"))
.stateQuery(count, new Fields("country", "contentName"), new MapGet(), new Fields("count"))
.groupBy(new Fields("country"))
.aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(3,"count", true), new Fields("contentName", "count"))
;
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
// public class ExtractLocation extends BaseFunction {
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Status status = (Status) tuple.get(0);
// Content content = (Content) tuple.get(1);
//
// collector.emit(new Values(status.getPlace().getCountryCode(), content.getContentName()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyGeo.java
// public class OnlyGeo extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Status status = (Status) tuple.get(0);
// return !(null == status.getPlace() || null == status.getPlace().getCountryCode());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByCountry.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractLocation;
import tutorial.storm.trident.operations.OnlyGeo;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
*
*/
public class TopHashtagByCountry {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("status", "content", "user"))
.project(new Fields("content", "user", "status"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("status"), new OnlyGeo())
.each(new Fields("status", "content"), new ExtractLocation(), new Fields("country", "contentName"))
.groupBy(new Fields("country", "contentName"))
.persistentAggregate(new MemoryMapState.Factory(), new Count(), new Fields("count"))
;
topology
.newDRPCStream("location_hashtag_count")
.stateQuery(count, new TupleCollectionGet(), new Fields("country", "contentName"))
.stateQuery(count, new Fields("country", "contentName"), new MapGet(), new Fields("count"))
.groupBy(new Fields("country"))
.aggregate(new Fields("contentName", "count"), new FirstN.FirstNSortedAgg(3,"count", true), new Fields("contentName", "count"))
;
return topology.build();
}
public static void main(String[] args) throws Exception {
Config conf = new Config();
if (args.length == 2) {
// Ready & submit the topology
String name = args[0];
BrokerHosts hosts = new ZkHosts(args[1]);
|
TransactionalTridentKafkaSpout kafkaSpout = TestUtils.testTweetSpout(hosts);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
|
import storm.trident.operation.BaseFilter;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
|
package tutorial.storm.trident.operations;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class OnlyHashtags extends BaseFilter {
@Override
public boolean isKeep(TridentTuple tuple) {
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
import storm.trident.operation.BaseFilter;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
package tutorial.storm.trident.operations;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class OnlyHashtags extends BaseFilter {
@Override
public boolean isKeep(TridentTuple tuple) {
|
Content content = (Content)tuple.get(0);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/operations/GetContentName.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
|
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
|
package tutorial.storm.trident.operations;
/**
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class GetContentName extends BaseFunction {
@Override
public void execute(TridentTuple objects, TridentCollector tridentCollector) {
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
// Path: src/main/java/tutorial/storm/trident/operations/GetContentName.java
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
package tutorial.storm.trident.operations;
/**
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class GetContentName extends BaseFunction {
@Override
public void execute(TridentTuple objects, TridentCollector tridentCollector) {
|
Content content = (Content) objects.getValueByField("content");
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
|
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
|
.each(new Fields("content"), new OnlyHashtags())
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
|
.each(new Fields("user"), new OnlyEnglish())
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
|
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
|
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
// public class ExtractFollowerClassAndContentName extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Content content = (Content)tuple.get(0);
// User user = (User)tuple.get(1);
//
// String followerClass = classify(user.getFollowersCount());
//
// collector.emit(new Values(followerClass, content.getContentName()));
// }
//
// private String classify(int followersCount) {
// if (followersCount < 100){
// return "< 100";
// } else if (followersCount < 10*1000){
// return "< 10K";
// } else if (followersCount < 100*1000){
// return "< 100K";
// } else {
// return ">= 100K";
// }
// }
//
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyEnglish.java
// public class OnlyEnglish extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// User user = (User)tuple.get(0);
//
// return "en".equals(user.getLang());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/OnlyHashtags.java
// public class OnlyHashtags extends BaseFilter {
// @Override
// public boolean isKeep(TridentTuple tuple) {
// Content content = (Content)tuple.get(0);
// return "hashtag".equals(content.getContentType());
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/ParseTweet.java
// public class ParseTweet extends BaseFunction {
// private static final Logger log = LoggerFactory.getLogger(ParseTweet.class);
//
// private ContentExtracter extracter;
//
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// if(extracter == null) extracter = new ContentExtracter();
//
// String rawTweetJson = (String)tuple.get(0);
// Status parsed = parse(rawTweetJson);
// User user = parsed.getUser();
//
// for (Content content : extracter.extract(parsed)) {
// collector.emit(new Values(parsed, content, user));
// }
// }
//
// private Status parse(String rawJson){
// try {
// Status parsed = DataObjectFactory.createStatus(rawJson);
// return parsed;
// } catch (TwitterException e) {
// log.warn("Invalid tweet json -> " + rawJson, e);
// return null;
// }
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/SampleTweet.java
// public class SampleTweet {
// private static final Logger log = LoggerFactory.getLogger(SampleTweet.class);
//
// private final Iterator<String> sampleTweet;
//
// public SampleTweet() throws IOException {
// ObjectMapper om = new ObjectMapper();
// JsonFactory factory = new JsonFactory();
// ImmutableList.Builder<String> b = ImmutableList.builder();
//
// InputStreamReader reader = new InputStreamReader(this.getClass().getResourceAsStream("sample_tweet.json"));
// try {
// String tweetArray = CharStreams.toString(reader);
// ArrayNode parsed = (ArrayNode)om.readTree(tweetArray);
// for (JsonNode tweet : parsed) {
// StringWriter sw = new StringWriter();
// om.writeTree(factory.createGenerator(sw), tweet);
// b.add(sw.toString());
// }
// sampleTweet = Iterators.cycle(b.build());
// } finally {
// reader.close();
// }
// }
//
// public String sampleTweet(){
// return sampleTweet.next();
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/TestUtils.java
// public class TestUtils {
// public static TransactionalTridentKafkaSpout testTweetSpout(BrokerHosts hosts) {
// TridentKafkaConfig kafkaConfig = new TridentKafkaConfig(hosts, "test", "storm");
// kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
// return new TransactionalTridentKafkaSpout(kafkaConfig);
// }
//
// }
// Path: src/main/java/tutorial/storm/trident/example/TopHashtagByFollowerClass.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.LocalDRPC;
import backtype.storm.StormSubmitter;
import backtype.storm.generated.StormTopology;
import backtype.storm.spout.SchemeAsMultiScheme;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import storm.kafka.BrokerHosts;
import storm.kafka.KafkaConfig;
import storm.kafka.StringScheme;
import storm.kafka.ZkHosts;
import storm.kafka.trident.TransactionalTridentKafkaSpout;
import storm.kafka.trident.TridentKafkaConfig;
import storm.trident.TridentState;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.FirstN;
import storm.trident.operation.builtin.MapGet;
import storm.trident.operation.builtin.TupleCollectionGet;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.ExtractFollowerClassAndContentName;
import tutorial.storm.trident.operations.OnlyEnglish;
import tutorial.storm.trident.operations.OnlyHashtags;
import tutorial.storm.trident.operations.ParseTweet;
import tutorial.storm.trident.testutil.SampleTweet;
import tutorial.storm.trident.testutil.TestUtils;
import java.io.IOException;
package tutorial.storm.trident.example;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class TopHashtagByFollowerClass {
public static StormTopology buildTopology(TransactionalTridentKafkaSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
TridentState count =
topology
.newStream("tweets", spout)
.each(new Fields("str"), new ParseTweet(), new Fields("text", "content", "user"))
.project(new Fields("content", "user"))
.each(new Fields("content"), new OnlyHashtags())
.each(new Fields("user"), new OnlyEnglish())
|
.each(new Fields("content", "user"), new ExtractFollowerClassAndContentName(), new Fields("followerClass", "contentName"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Part02_AdvancedPrimitives1.java
|
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/StringCounter.java
// public class StringCounter implements Aggregator<Map<String, Integer>> {
//
// private int partitionId;
// private int numPartitions;
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionId = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
// @Override
// public void cleanup() {
// }
//
// @Override
// public Map<String, Integer> init(Object batchId, TridentCollector collector) {
// return new HashMap<String, Integer>();
// }
//
// @Override
// public void aggregate(Map<String, Integer> val, TridentTuple tuple, TridentCollector collector) {
// String loc = tuple.getString(0);
// Integer previousValue = val.get(loc);
// previousValue = previousValue == null ? 0 : previousValue;
// val.put(loc, previousValue + 1);
// }
//
// @Override
// public void complete(Map<String, Integer> val, TridentCollector collector) {
// System.err.println(String.format("Partition %s out ot %s partitions aggregated:%s", partitionId, numPartitions, val));
// collector.emit(new Values(val));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFilter;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.operations.Print;
import tutorial.storm.trident.operations.StringCounter;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
import java.util.HashMap;
import java.util.Map;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part02_AdvancedPrimitives1 {
private static final Logger log = LoggerFactory.getLogger(Part02_AdvancedPrimitives1.class);
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
|
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/StringCounter.java
// public class StringCounter implements Aggregator<Map<String, Integer>> {
//
// private int partitionId;
// private int numPartitions;
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionId = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
// @Override
// public void cleanup() {
// }
//
// @Override
// public Map<String, Integer> init(Object batchId, TridentCollector collector) {
// return new HashMap<String, Integer>();
// }
//
// @Override
// public void aggregate(Map<String, Integer> val, TridentTuple tuple, TridentCollector collector) {
// String loc = tuple.getString(0);
// Integer previousValue = val.get(loc);
// previousValue = previousValue == null ? 0 : previousValue;
// val.put(loc, previousValue + 1);
// }
//
// @Override
// public void complete(Map<String, Integer> val, TridentCollector collector) {
// System.err.println(String.format("Partition %s out ot %s partitions aggregated:%s", partitionId, numPartitions, val));
// collector.emit(new Values(val));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
// Path: src/main/java/tutorial/storm/trident/Part02_AdvancedPrimitives1.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFilter;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.operations.Print;
import tutorial.storm.trident.operations.StringCounter;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
import java.util.HashMap;
import java.util.Map;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part02_AdvancedPrimitives1 {
private static final Logger log = LoggerFactory.getLogger(Part02_AdvancedPrimitives1.class);
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
|
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(new FakeTweetsBatchSpout(1000)));
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Part02_AdvancedPrimitives1.java
|
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/StringCounter.java
// public class StringCounter implements Aggregator<Map<String, Integer>> {
//
// private int partitionId;
// private int numPartitions;
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionId = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
// @Override
// public void cleanup() {
// }
//
// @Override
// public Map<String, Integer> init(Object batchId, TridentCollector collector) {
// return new HashMap<String, Integer>();
// }
//
// @Override
// public void aggregate(Map<String, Integer> val, TridentTuple tuple, TridentCollector collector) {
// String loc = tuple.getString(0);
// Integer previousValue = val.get(loc);
// previousValue = previousValue == null ? 0 : previousValue;
// val.put(loc, previousValue + 1);
// }
//
// @Override
// public void complete(Map<String, Integer> val, TridentCollector collector) {
// System.err.println(String.format("Partition %s out ot %s partitions aggregated:%s", partitionId, numPartitions, val));
// collector.emit(new Values(val));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFilter;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.operations.Print;
import tutorial.storm.trident.operations.StringCounter;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
import java.util.HashMap;
import java.util.Map;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part02_AdvancedPrimitives1 {
private static final Logger log = LoggerFactory.getLogger(Part02_AdvancedPrimitives1.class);
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(new FakeTweetsBatchSpout(1000)));
Thread.sleep(30000);
cluster.shutdown();
}
private static StormTopology advancedPrimitives(FakeTweetsBatchSpout spout) {
TridentTopology topology = new TridentTopology();
// We have seen how to use groupBy, but you can use a more low-level form of aggregation as well
// This example keeps track of counts, but this time it aggregates the result into a hash map
topology
.newStream("aggregation", spout)
|
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/StringCounter.java
// public class StringCounter implements Aggregator<Map<String, Integer>> {
//
// private int partitionId;
// private int numPartitions;
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionId = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
// @Override
// public void cleanup() {
// }
//
// @Override
// public Map<String, Integer> init(Object batchId, TridentCollector collector) {
// return new HashMap<String, Integer>();
// }
//
// @Override
// public void aggregate(Map<String, Integer> val, TridentTuple tuple, TridentCollector collector) {
// String loc = tuple.getString(0);
// Integer previousValue = val.get(loc);
// previousValue = previousValue == null ? 0 : previousValue;
// val.put(loc, previousValue + 1);
// }
//
// @Override
// public void complete(Map<String, Integer> val, TridentCollector collector) {
// System.err.println(String.format("Partition %s out ot %s partitions aggregated:%s", partitionId, numPartitions, val));
// collector.emit(new Values(val));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/testutil/FakeTweetsBatchSpout.java
// @SuppressWarnings({"serial", "rawtypes"})
// public class FakeTweetsBatchSpout implements IBatchSpout {
// private static final AtomicInteger seq = new AtomicInteger();
//
// private int batchSize;
// private FakeTweetGenerator fakeTweetGenerator;
//
//
// public FakeTweetsBatchSpout() throws IOException {
// this(5);
// }
//
// public FakeTweetsBatchSpout(int batchSize) throws IOException {
// this.batchSize = batchSize;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public void open(Map conf, TopologyContext context) {
// // init
// System.err.println(this.getClass().getSimpleName() +":" + seq.incrementAndGet()+" opened.");
// fakeTweetGenerator = new FakeTweetGenerator();
//
// }
//
// @Override
// public void emitBatch(long batchId, TridentCollector collector) {
// // emit batchSize fake tweets
// for (int i = 0; i < batchSize; i++) {
// collector.emit(fakeTweetGenerator.getNextTweet());
// }
// }
//
// @Override
// public void ack(long batchId) {
// // nothing to do here
// }
//
// @Override
// public void close() {
// // nothing to do here
// }
//
// @Override
// public Map getComponentConfiguration() {
// // no particular configuration here
// return new Config();
// }
//
// @Override
// public Fields getOutputFields() {
// return new Fields("id", "text", "actor", "location", "date");
// }
// }
// Path: src/main/java/tutorial/storm/trident/Part02_AdvancedPrimitives1.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import storm.trident.TridentTopology;
import storm.trident.operation.BaseFilter;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.operations.Print;
import tutorial.storm.trident.operations.StringCounter;
import tutorial.storm.trident.testutil.FakeTweetsBatchSpout;
import java.util.HashMap;
import java.util.Map;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part02_AdvancedPrimitives1 {
private static final Logger log = LoggerFactory.getLogger(Part02_AdvancedPrimitives1.class);
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(new FakeTweetsBatchSpout(1000)));
Thread.sleep(30000);
cluster.shutdown();
}
private static StormTopology advancedPrimitives(FakeTweetsBatchSpout spout) {
TridentTopology topology = new TridentTopology();
// We have seen how to use groupBy, but you can use a more low-level form of aggregation as well
// This example keeps track of counts, but this time it aggregates the result into a hash map
topology
.newStream("aggregation", spout)
|
.aggregate(new Fields("location"), new StringCounter(), new Fields("aggregated_result"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/operations/TweetIdExtractor.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
|
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
|
package tutorial.storm.trident.operations;
/**
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class TweetIdExtractor extends BaseFunction {
@Override
public void execute(TridentTuple objects, TridentCollector tridentCollector) {
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
// Path: src/main/java/tutorial/storm/trident/operations/TweetIdExtractor.java
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
package tutorial.storm.trident.operations;
/**
* @author Davide Palmisano (davide.palmisano@peerindex.com)
*/
public class TweetIdExtractor extends BaseFunction {
@Override
public void execute(TridentTuple objects, TridentCollector tridentCollector) {
|
Content content = (Content) objects.getValueByField("content");
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Part03_AdvancedPrimitives2.java
|
// Path: src/main/java/tutorial/storm/trident/operations/DivideAsDouble.java
// public class DivideAsDouble extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Number n1 = (Number)tuple.get(0);
// Number n2 = (Number)tuple.get(1);
// collector.emit(new Values(n1.doubleValue() / n2.doubleValue()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.collect.ImmutableList;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.DivideAsDouble;
import tutorial.storm.trident.operations.Print;
import java.io.IOException;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part03_AdvancedPrimitives2 {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
// This time we use a "FeederBatchSpout", a spout designed for testing.
FeederBatchSpout testSpout = new FeederBatchSpout(ImmutableList.of("name", "city", "age"));
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(testSpout));
// You can "hand feed" values to the topology by using this spout
testSpout.feed(ImmutableList.of(new Values("rose", "Shanghai", 32), new Values("mary", "Shanghai", 51), new Values("pere", "Jakarta", 65), new Values("Tom", "Jakarta", 10)));
}
private static StormTopology advancedPrimitives(FeederBatchSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
// What if we want more than one aggregation? For that, we can use "chained" aggregations.
// Note how we calculate count and sum.
// The aggregated values can then be processed further, in this case into mean
topology
.newStream("aggregation", spout)
.groupBy(new Fields("city"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
.chainEnd()
|
// Path: src/main/java/tutorial/storm/trident/operations/DivideAsDouble.java
// public class DivideAsDouble extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Number n1 = (Number)tuple.get(0);
// Number n2 = (Number)tuple.get(1);
// collector.emit(new Values(n1.doubleValue() / n2.doubleValue()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
// Path: src/main/java/tutorial/storm/trident/Part03_AdvancedPrimitives2.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.collect.ImmutableList;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.DivideAsDouble;
import tutorial.storm.trident.operations.Print;
import java.io.IOException;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part03_AdvancedPrimitives2 {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
// This time we use a "FeederBatchSpout", a spout designed for testing.
FeederBatchSpout testSpout = new FeederBatchSpout(ImmutableList.of("name", "city", "age"));
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(testSpout));
// You can "hand feed" values to the topology by using this spout
testSpout.feed(ImmutableList.of(new Values("rose", "Shanghai", 32), new Values("mary", "Shanghai", 51), new Values("pere", "Jakarta", 65), new Values("Tom", "Jakarta", 10)));
}
private static StormTopology advancedPrimitives(FeederBatchSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
// What if we want more than one aggregation? For that, we can use "chained" aggregations.
// Note how we calculate count and sum.
// The aggregated values can then be processed further, in this case into mean
topology
.newStream("aggregation", spout)
.groupBy(new Fields("city"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
.chainEnd()
|
.each(new Fields("age_sum", "count"), new DivideAsDouble(), new Fields("mean_age"))
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/Part03_AdvancedPrimitives2.java
|
// Path: src/main/java/tutorial/storm/trident/operations/DivideAsDouble.java
// public class DivideAsDouble extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Number n1 = (Number)tuple.get(0);
// Number n2 = (Number)tuple.get(1);
// collector.emit(new Values(n1.doubleValue() / n2.doubleValue()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
|
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.collect.ImmutableList;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.DivideAsDouble;
import tutorial.storm.trident.operations.Print;
import java.io.IOException;
|
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part03_AdvancedPrimitives2 {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
// This time we use a "FeederBatchSpout", a spout designed for testing.
FeederBatchSpout testSpout = new FeederBatchSpout(ImmutableList.of("name", "city", "age"));
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(testSpout));
// You can "hand feed" values to the topology by using this spout
testSpout.feed(ImmutableList.of(new Values("rose", "Shanghai", 32), new Values("mary", "Shanghai", 51), new Values("pere", "Jakarta", 65), new Values("Tom", "Jakarta", 10)));
}
private static StormTopology advancedPrimitives(FeederBatchSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
// What if we want more than one aggregation? For that, we can use "chained" aggregations.
// Note how we calculate count and sum.
// The aggregated values can then be processed further, in this case into mean
topology
.newStream("aggregation", spout)
.groupBy(new Fields("city"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
.chainEnd()
.each(new Fields("age_sum", "count"), new DivideAsDouble(), new Fields("mean_age"))
|
// Path: src/main/java/tutorial/storm/trident/operations/DivideAsDouble.java
// public class DivideAsDouble extends BaseFunction {
// @Override
// public void execute(TridentTuple tuple, TridentCollector collector) {
// Number n1 = (Number)tuple.get(0);
// Number n2 = (Number)tuple.get(1);
// collector.emit(new Values(n1.doubleValue() / n2.doubleValue()));
// }
// }
//
// Path: src/main/java/tutorial/storm/trident/operations/Print.java
// public class Print extends BaseFilter {
// private int partitionIndex;
// private int numPartitions;
// private final String name;
//
// public Print(){
// name = "";
// }
// public Print(String name){
// this.name = name;
// }
//
// @Override
// public void prepare(Map conf, TridentOperationContext context) {
// this.partitionIndex = context.getPartitionIndex();
// this.numPartitions = context.numPartitions();
// }
//
//
// @Override
// public boolean isKeep(TridentTuple tuple) {
// System.err.println(String.format("%s::Partition idx: %s out of %s partitions got %s", name, partitionIndex, numPartitions, tuple.toString()));
// return true;
// }
// }
// Path: src/main/java/tutorial/storm/trident/Part03_AdvancedPrimitives2.java
import backtype.storm.Config;
import backtype.storm.LocalCluster;
import backtype.storm.generated.StormTopology;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Values;
import com.google.common.collect.ImmutableList;
import storm.trident.TridentTopology;
import storm.trident.operation.builtin.Count;
import storm.trident.operation.builtin.Sum;
import storm.trident.testing.FeederBatchSpout;
import storm.trident.testing.MemoryMapState;
import tutorial.storm.trident.operations.DivideAsDouble;
import tutorial.storm.trident.operations.Print;
import java.io.IOException;
package tutorial.storm.trident;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class Part03_AdvancedPrimitives2 {
public static void main(String[] args) throws Exception {
Config conf = new Config();
// conf.put(Config.TOPOLOGY_DEBUG,true);
LocalCluster cluster = new LocalCluster();
// This time we use a "FeederBatchSpout", a spout designed for testing.
FeederBatchSpout testSpout = new FeederBatchSpout(ImmutableList.of("name", "city", "age"));
cluster.submitTopology("advanced_primitives", conf, advancedPrimitives(testSpout));
// You can "hand feed" values to the topology by using this spout
testSpout.feed(ImmutableList.of(new Values("rose", "Shanghai", 32), new Values("mary", "Shanghai", 51), new Values("pere", "Jakarta", 65), new Values("Tom", "Jakarta", 10)));
}
private static StormTopology advancedPrimitives(FeederBatchSpout spout) throws IOException {
TridentTopology topology = new TridentTopology();
// What if we want more than one aggregation? For that, we can use "chained" aggregations.
// Note how we calculate count and sum.
// The aggregated values can then be processed further, in this case into mean
topology
.newStream("aggregation", spout)
.groupBy(new Fields("city"))
.chainedAgg()
.aggregate(new Count(), new Fields("count"))
.aggregate(new Fields("age"), new Sum(), new Fields("age_sum"))
.chainEnd()
.each(new Fields("age_sum", "count"), new DivideAsDouble(), new Fields("mean_age"))
|
.each(new Fields("city", "mean_age"), new Print())
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
|
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
import twitter4j.Status;
|
package tutorial.storm.trident.operations;
/**
*
*/
public class ExtractLocation extends BaseFunction {
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
Status status = (Status) tuple.get(0);
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
// Path: src/main/java/tutorial/storm/trident/operations/ExtractLocation.java
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
import twitter4j.Status;
package tutorial.storm.trident.operations;
/**
*
*/
public class ExtractLocation extends BaseFunction {
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
Status status = (Status) tuple.get(0);
|
Content content = (Content) tuple.get(1);
|
eshioji/trident-tutorial
|
src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
|
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
import twitter4j.User;
|
package tutorial.storm.trident.operations;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class ExtractFollowerClassAndContentName extends BaseFunction {
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
|
// Path: src/main/java/tutorial/storm/trident/testutil/Content.java
// public class Content {
// private static final Logger log = LoggerFactory.getLogger(Content.class);
//
// private long tweetId;
// private long userId;
// private long createdAtMs;
//
// private String contentName;
// private String contentType;
//
// public Content(long tweetId, long userId, long createdAtMs) {
// this.tweetId = tweetId;
// this.userId = userId;
// this.createdAtMs = createdAtMs;
// }
//
// public String getContentId(){
// HashFunction md5 = Hashing.md5();
// return md5.hashString(contentType + contentName).toString();
// }
//
// public String getContentName() {
// return contentName;
// }
//
// public void setContentName(String contentName) {
// this.contentName = contentName;
// }
//
// public void setContentType(String contentType) {
// this.contentType = contentType;
// }
//
// public long getTweetId() {
// return tweetId;
// }
//
// public void setTweetId(long tweetId) {
// this.tweetId = tweetId;
// }
//
// public long getUserId() {
// return userId;
// }
//
// public void setUserId(long userId) {
// this.userId = userId;
// }
//
// public long getCreatedAtMs() {
// return createdAtMs;
// }
//
// public void setCreatedAtMs(long createdAtMs) {
// this.createdAtMs = createdAtMs;
// }
//
// @Override
// public String toString() {
// return "Content{" +
// "contentType='" + contentType + '\'' +
// ", contentName='" + contentName + '\'' +
// '}';
// }
//
// public String getContentType() {
// return contentType;
// }
// }
// Path: src/main/java/tutorial/storm/trident/operations/ExtractFollowerClassAndContentName.java
import backtype.storm.tuple.Values;
import storm.trident.operation.BaseFunction;
import storm.trident.operation.TridentCollector;
import storm.trident.tuple.TridentTuple;
import tutorial.storm.trident.testutil.Content;
import twitter4j.User;
package tutorial.storm.trident.operations;
/**
* @author Enno Shioji (enno.shioji@peerindex.com)
*/
public class ExtractFollowerClassAndContentName extends BaseFunction {
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
|
Content content = (Content)tuple.get(0);
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.github.peckb1.examples.base.fraggles.Wembley;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.util.Optional;
|
package com.github.peckb1.examples.base;
@JsonTypeInfo(use = Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "name") // not compile time checked
@JsonSubTypes({
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.github.peckb1.examples.base.fraggles.Wembley;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.util.Optional;
package com.github.peckb1.examples.base;
@JsonTypeInfo(use = Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "name") // not compile time checked
@JsonSubTypes({
|
@Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.github.peckb1.examples.base.fraggles.Wembley;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.util.Optional;
|
package com.github.peckb1.examples.base;
@JsonTypeInfo(use = Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "name") // not compile time checked
@JsonSubTypes({
@Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.github.peckb1.examples.base.fraggles.Wembley;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.util.Optional;
package com.github.peckb1.examples.base;
@JsonTypeInfo(use = Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "name") // not compile time checked
@JsonSubTypes({
@Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
|
@Type(value = Boober.class, name = "BOOBER") // not compile time checked
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
|
package com.github.peckb1.examples.base;
public class TestBaseModel {
private ObjectMapper objectMapper;
@Before
public void setUp() throws Exception {
this.objectMapper = new ObjectMapper();
this.objectMapper.registerModule(new Jdk8Module());
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
AutoJacksonSetup.configureObjectMapper(this.objectMapper);
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
// Path: examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
package com.github.peckb1.examples.base;
public class TestBaseModel {
private ObjectMapper objectMapper;
@Before
public void setUp() throws Exception {
this.objectMapper = new ObjectMapper();
this.objectMapper.registerModule(new Jdk8Module());
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
AutoJacksonSetup.configureObjectMapper(this.objectMapper);
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
|
Assert.assertTrue(fraggle instanceof Wembley);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
|
package com.github.peckb1.examples.base;
public class TestBaseModel {
private ObjectMapper objectMapper;
@Before
public void setUp() throws Exception {
this.objectMapper = new ObjectMapper();
this.objectMapper.registerModule(new Jdk8Module());
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
AutoJacksonSetup.configureObjectMapper(this.objectMapper);
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
Assert.assertTrue(fraggle instanceof Wembley);
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
// Path: examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
package com.github.peckb1.examples.base;
public class TestBaseModel {
private ObjectMapper objectMapper;
@Before
public void setUp() throws Exception {
this.objectMapper = new ObjectMapper();
this.objectMapper.registerModule(new Jdk8Module());
this.objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
this.objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
AutoJacksonSetup.configureObjectMapper(this.objectMapper);
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
Assert.assertTrue(fraggle instanceof Wembley);
|
Assert.assertEquals(FraggleName.WEMBLEY, fraggle.getFraggleName());
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
|
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
Assert.assertTrue(fraggle instanceof Wembley);
Assert.assertEquals(FraggleName.WEMBLEY, fraggle.getFraggleName());
Assert.assertEquals("yellow", fraggle.getHairColour());
Assert.assertEquals(false, fraggle.wearsHats());
Assert.assertFalse(fraggle.getJob().isPresent());
}
private void checkBoober(Fraggle fraggle) {
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
// public class Wembley extends Fraggle {
// public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.WEMBLEY;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
// public class Boober extends Fraggle {
// public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
// @JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
// @JsonProperty(value = JOB_KEY) Optional<Job> job) {
// super(hairColour, wearsHats, job);
// }
//
// @Override
// public FraggleName getFraggleName() {
// return FraggleName.BOOBER;
// }
// }
// Path: examples/src/test/java/com/github/peckb1/examples/base/TestBaseModel.java
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.github.peckb1.examples.base.fraggles.Wembley;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.base.Fraggle.FraggleName;
import com.github.peckb1.examples.base.fraggles.Boober;
import java.io.File;
import java.io.IOException;
import java.util.List;
}
@Test
public void testSimpleModel() throws IOException {
File baseModelFile = new File("resources/base_model.json");
FraggleList fraggleList = this.objectMapper.readValue(baseModelFile, FraggleList.class);
checkFraggleList(fraggleList);
String fraggleListJson = this.objectMapper.writeValueAsString(fraggleList);
FraggleList fraggleListAgain = this.objectMapper.readValue(fraggleListJson, FraggleList.class);
checkFraggleList(fraggleListAgain);
}
private void checkFraggleList(FraggleList fraggleListAgain) {
List<Fraggle> fraggles = fraggleListAgain.getFraggles();
checkBoober(fraggles.get(0));
checkWembley(fraggles.get(1));
}
private void checkWembley(Fraggle fraggle) {
Assert.assertTrue(fraggle instanceof Wembley);
Assert.assertEquals(FraggleName.WEMBLEY, fraggle.getFraggleName());
Assert.assertEquals("yellow", fraggle.getHairColour());
Assert.assertEquals(false, fraggle.wearsHats());
Assert.assertFalse(fraggle.getJob().isPresent());
}
private void checkBoober(Fraggle fraggle) {
|
Assert.assertTrue(fraggle instanceof Boober);
|
peckb1/autojackson
|
processor/src/main/java/com/github/peckb1/processor/util/SetupCreator.java
|
// Path: processor/src/main/java/com/github/peckb1/processor/util/DeserializerCreator.java
// final static String DESERIALIZER_CLASS_NAME_SUFFIX = "_AutoJacksonDeserializer";
|
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.github.peckb1.processor.AutoJackson;
import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.TypeSpec;
import javax.annotation.processing.Filer;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import java.io.IOException;
import java.util.List;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.PropertyAccessor.ALL;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static com.github.peckb1.processor.util.DeserializerCreator.DESERIALIZER_CLASS_NAME_SUFFIX;
|
package com.github.peckb1.processor.util;
/**
* Creates a single class that can be used to setup an {@link ObjectMapper}
* with the deserializers and Jackson settings needed to allow the
* {@link AutoJackson} to function correctly.
* <p>
* The class created is only a helper method to avoid the boiler plate of
* adding in each deserializer created for each class annotated with
* our {@link AutoJackson} annotation. But the steps
* performed inside can be done manually by the user if wanted.
*/
public class SetupCreator {
private final Filer filer;
private final ProcessorUtil processorUtil;
public SetupCreator(Filer filer, ProcessorUtil processorUtil) {
this.filer = filer;
this.processorUtil = processorUtil;
}
public void createSetupClass(ImmutableList<TypeElement> interfaces) {
MethodSpec constructor = MethodSpec.constructorBuilder()
.addModifiers(Modifier.PRIVATE)
.build();
MethodSpec.Builder configurationMethodBuilder = MethodSpec.methodBuilder("configureObjectMapper")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addParameter(ParameterSpec.builder(ObjectMapper.class, "objectMapper").build())
.addStatement("$T deserialzationModule = new $T()", SimpleModule.class, SimpleModule.class);
interfaces.forEach(element -> {
String deserializationPackage = ClassName.get(element).packageName();
|
// Path: processor/src/main/java/com/github/peckb1/processor/util/DeserializerCreator.java
// final static String DESERIALIZER_CLASS_NAME_SUFFIX = "_AutoJacksonDeserializer";
// Path: processor/src/main/java/com/github/peckb1/processor/util/SetupCreator.java
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.github.peckb1.processor.AutoJackson;
import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterSpec;
import com.squareup.javapoet.TypeSpec;
import javax.annotation.processing.Filer;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import java.io.IOException;
import java.util.List;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.PropertyAccessor.ALL;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static com.github.peckb1.processor.util.DeserializerCreator.DESERIALIZER_CLASS_NAME_SUFFIX;
package com.github.peckb1.processor.util;
/**
* Creates a single class that can be used to setup an {@link ObjectMapper}
* with the deserializers and Jackson settings needed to allow the
* {@link AutoJackson} to function correctly.
* <p>
* The class created is only a helper method to avoid the boiler plate of
* adding in each deserializer created for each class annotated with
* our {@link AutoJackson} annotation. But the steps
* performed inside can be done manually by the user if wanted.
*/
public class SetupCreator {
private final Filer filer;
private final ProcessorUtil processorUtil;
public SetupCreator(Filer filer, ProcessorUtil processorUtil) {
this.filer = filer;
this.processorUtil = processorUtil;
}
public void createSetupClass(ImmutableList<TypeElement> interfaces) {
MethodSpec constructor = MethodSpec.constructorBuilder()
.addModifiers(Modifier.PRIVATE)
.build();
MethodSpec.Builder configurationMethodBuilder = MethodSpec.methodBuilder("configureObjectMapper")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.addParameter(ParameterSpec.builder(ObjectMapper.class, "objectMapper").build())
.addStatement("$T deserialzationModule = new $T()", SimpleModule.class, SimpleModule.class);
interfaces.forEach(element -> {
String deserializationPackage = ClassName.get(element).packageName();
|
ClassName deserializerClassName = ClassName.get(deserializationPackage, element.getSimpleName() + DESERIALIZER_CLASS_NAME_SUFFIX);
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// @JsonTypeInfo(use = Id.NAME,
// include = JsonTypeInfo.As.PROPERTY,
// property = "name") // not compile time checked
// @JsonSubTypes({
// @Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
// @Type(value = Boober.class, name = "BOOBER") // not compile time checked
// })
// public abstract class Fraggle {
// protected static final String HAIR_COLOUR_KEY = "hairColour";
// protected static final String HAT_KEY = "hat";
// protected static final String JOB_KEY = "job";
//
// @JsonProperty(value = HAIR_COLOUR_KEY, required = true)
// private final String hairColour;
//
// @JsonProperty(value = HAT_KEY, required = true)
// private final Boolean wearsHats;
//
// @JsonProperty(value = JOB_KEY)
// private final Optional<Job> job;
//
// protected Fraggle(String hairColour, Boolean wearsHats, Optional<Job> job) {
// this.hairColour = hairColour;
// this.wearsHats = wearsHats;
// this.job = job;
// }
//
// @JsonIgnore
// public abstract FraggleName getFraggleName();
//
// public String getHairColour() {
// return this.hairColour;
// }
//
// public Boolean wearsHats() {
// return this.wearsHats;
// }
//
// public Optional<Job> getJob() {
// return this.job;
// }
//
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Job.java
// public class Job {
// private static final String OCCUPATION_KEY = "occupation";
// private static final String DAYS_WORKED_KEY = "daysWorked";
//
// @JsonProperty(value = OCCUPATION_KEY, required = true)
// private final String occupation;
//
// @JsonProperty(value = DAYS_WORKED_KEY, required = true)
// private final int daysWorked;
//
// public Job(@JsonProperty(value = OCCUPATION_KEY, required = true) String occupation,
// @JsonProperty(value = DAYS_WORKED_KEY, required = true) int daysWorked) {
// this.occupation = occupation;
// this.daysWorked = daysWorked;
// }
//
// public String getOccupation() {
// return this.occupation;
// }
//
// public int getDaysWorked() {
// return this.daysWorked;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.peckb1.examples.base.Fraggle;
import com.github.peckb1.examples.base.Job;
import java.util.Optional;
|
package com.github.peckb1.examples.base.fraggles;
public class Wembley extends Fraggle {
public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
@JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// @JsonTypeInfo(use = Id.NAME,
// include = JsonTypeInfo.As.PROPERTY,
// property = "name") // not compile time checked
// @JsonSubTypes({
// @Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
// @Type(value = Boober.class, name = "BOOBER") // not compile time checked
// })
// public abstract class Fraggle {
// protected static final String HAIR_COLOUR_KEY = "hairColour";
// protected static final String HAT_KEY = "hat";
// protected static final String JOB_KEY = "job";
//
// @JsonProperty(value = HAIR_COLOUR_KEY, required = true)
// private final String hairColour;
//
// @JsonProperty(value = HAT_KEY, required = true)
// private final Boolean wearsHats;
//
// @JsonProperty(value = JOB_KEY)
// private final Optional<Job> job;
//
// protected Fraggle(String hairColour, Boolean wearsHats, Optional<Job> job) {
// this.hairColour = hairColour;
// this.wearsHats = wearsHats;
// this.job = job;
// }
//
// @JsonIgnore
// public abstract FraggleName getFraggleName();
//
// public String getHairColour() {
// return this.hairColour;
// }
//
// public Boolean wearsHats() {
// return this.wearsHats;
// }
//
// public Optional<Job> getJob() {
// return this.job;
// }
//
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Job.java
// public class Job {
// private static final String OCCUPATION_KEY = "occupation";
// private static final String DAYS_WORKED_KEY = "daysWorked";
//
// @JsonProperty(value = OCCUPATION_KEY, required = true)
// private final String occupation;
//
// @JsonProperty(value = DAYS_WORKED_KEY, required = true)
// private final int daysWorked;
//
// public Job(@JsonProperty(value = OCCUPATION_KEY, required = true) String occupation,
// @JsonProperty(value = DAYS_WORKED_KEY, required = true) int daysWorked) {
// this.occupation = occupation;
// this.daysWorked = daysWorked;
// }
//
// public String getOccupation() {
// return this.occupation;
// }
//
// public int getDaysWorked() {
// return this.daysWorked;
// }
// }
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Wembley.java
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.peckb1.examples.base.Fraggle;
import com.github.peckb1.examples.base.Job;
import java.util.Optional;
package com.github.peckb1.examples.base.fraggles;
public class Wembley extends Fraggle {
public Wembley(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
@JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
|
@JsonProperty(value = JOB_KEY) Optional<Job> job) {
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// @JsonTypeInfo(use = Id.NAME,
// include = JsonTypeInfo.As.PROPERTY,
// property = "name") // not compile time checked
// @JsonSubTypes({
// @Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
// @Type(value = Boober.class, name = "BOOBER") // not compile time checked
// })
// public abstract class Fraggle {
// protected static final String HAIR_COLOUR_KEY = "hairColour";
// protected static final String HAT_KEY = "hat";
// protected static final String JOB_KEY = "job";
//
// @JsonProperty(value = HAIR_COLOUR_KEY, required = true)
// private final String hairColour;
//
// @JsonProperty(value = HAT_KEY, required = true)
// private final Boolean wearsHats;
//
// @JsonProperty(value = JOB_KEY)
// private final Optional<Job> job;
//
// protected Fraggle(String hairColour, Boolean wearsHats, Optional<Job> job) {
// this.hairColour = hairColour;
// this.wearsHats = wearsHats;
// this.job = job;
// }
//
// @JsonIgnore
// public abstract FraggleName getFraggleName();
//
// public String getHairColour() {
// return this.hairColour;
// }
//
// public Boolean wearsHats() {
// return this.wearsHats;
// }
//
// public Optional<Job> getJob() {
// return this.job;
// }
//
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Job.java
// public class Job {
// private static final String OCCUPATION_KEY = "occupation";
// private static final String DAYS_WORKED_KEY = "daysWorked";
//
// @JsonProperty(value = OCCUPATION_KEY, required = true)
// private final String occupation;
//
// @JsonProperty(value = DAYS_WORKED_KEY, required = true)
// private final int daysWorked;
//
// public Job(@JsonProperty(value = OCCUPATION_KEY, required = true) String occupation,
// @JsonProperty(value = DAYS_WORKED_KEY, required = true) int daysWorked) {
// this.occupation = occupation;
// this.daysWorked = daysWorked;
// }
//
// public String getOccupation() {
// return this.occupation;
// }
//
// public int getDaysWorked() {
// return this.daysWorked;
// }
// }
|
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.peckb1.examples.base.Fraggle;
import com.github.peckb1.examples.base.Job;
import java.util.Optional;
|
package com.github.peckb1.examples.base.fraggles;
public class Boober extends Fraggle {
public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
@JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
|
// Path: examples/src/main/java/com/github/peckb1/examples/base/Fraggle.java
// @JsonTypeInfo(use = Id.NAME,
// include = JsonTypeInfo.As.PROPERTY,
// property = "name") // not compile time checked
// @JsonSubTypes({
// @Type(value = Wembley.class, name = "WEMBLEY"), // not compile time checked
// @Type(value = Boober.class, name = "BOOBER") // not compile time checked
// })
// public abstract class Fraggle {
// protected static final String HAIR_COLOUR_KEY = "hairColour";
// protected static final String HAT_KEY = "hat";
// protected static final String JOB_KEY = "job";
//
// @JsonProperty(value = HAIR_COLOUR_KEY, required = true)
// private final String hairColour;
//
// @JsonProperty(value = HAT_KEY, required = true)
// private final Boolean wearsHats;
//
// @JsonProperty(value = JOB_KEY)
// private final Optional<Job> job;
//
// protected Fraggle(String hairColour, Boolean wearsHats, Optional<Job> job) {
// this.hairColour = hairColour;
// this.wearsHats = wearsHats;
// this.job = job;
// }
//
// @JsonIgnore
// public abstract FraggleName getFraggleName();
//
// public String getHairColour() {
// return this.hairColour;
// }
//
// public Boolean wearsHats() {
// return this.wearsHats;
// }
//
// public Optional<Job> getJob() {
// return this.job;
// }
//
// public enum FraggleName {
// WEMBLEY, BOOBER
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/base/Job.java
// public class Job {
// private static final String OCCUPATION_KEY = "occupation";
// private static final String DAYS_WORKED_KEY = "daysWorked";
//
// @JsonProperty(value = OCCUPATION_KEY, required = true)
// private final String occupation;
//
// @JsonProperty(value = DAYS_WORKED_KEY, required = true)
// private final int daysWorked;
//
// public Job(@JsonProperty(value = OCCUPATION_KEY, required = true) String occupation,
// @JsonProperty(value = DAYS_WORKED_KEY, required = true) int daysWorked) {
// this.occupation = occupation;
// this.daysWorked = daysWorked;
// }
//
// public String getOccupation() {
// return this.occupation;
// }
//
// public int getDaysWorked() {
// return this.daysWorked;
// }
// }
// Path: examples/src/main/java/com/github/peckb1/examples/base/fraggles/Boober.java
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.peckb1.examples.base.Fraggle;
import com.github.peckb1.examples.base.Job;
import java.util.Optional;
package com.github.peckb1.examples.base.fraggles;
public class Boober extends Fraggle {
public Boober(@JsonProperty(value = HAIR_COLOUR_KEY, required = true) String hairColour,
@JsonProperty(value = HAT_KEY, required = true) Boolean wearsHats,
|
@JsonProperty(value = JOB_KEY) Optional<Job> job) {
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
|
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
|
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
|
GOBO(Gobo.class),
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
|
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
|
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
|
MOKEY(Mokey.class),
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
|
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
|
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
|
WEMBLEY(Wembley.class),
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
|
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
|
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
WEMBLEY(Wembley.class),
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
WEMBLEY(Wembley.class),
|
BOOBER(Boober.class),
|
peckb1/autojackson
|
examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
|
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
|
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
WEMBLEY(Wembley.class),
BOOBER(Boober.class),
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Red.java
// @AutoJackson
// public interface Red extends Fraggle<KarenPrell> {
//
// @Named("dives") int getDives();
//
// }
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Red;
import com.github.peckb1.processor.AutoJackson;
import com.github.peckb1.processor.AutoJacksonTypeClass;
import com.github.peckb1.processor.Named;
import java.util.Optional;
package com.github.peckb1.examples.auto;
@AutoJackson(type = @AutoJackson.Type(FraggleName.class))
public interface Fraggle<M extends Muppeteer> {
FraggleName getName();
Integer getAge();
@Named("occupation") String getJob();
Optional<Fraggle> getRoommate();
M getMuppeteer();
enum FraggleName {
GOBO(Gobo.class),
MOKEY(Mokey.class),
WEMBLEY(Wembley.class),
BOOBER(Boober.class),
|
RED(Red.class);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
Gorg[] gorgArray = sample.getGorgArray();
assertEquals(2, gorgArray.length);
checkQueen(gorgArray[0]);
checkKing(gorgArray[1]);
assertEquals(Instant.parse("2000-01-01T00:00:00Z"), sample.getStartTime());
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Gorg[] gorgArray = sample.getGorgArray();
assertEquals(2, gorgArray.length);
checkQueen(gorgArray[0]);
checkKing(gorgArray[1]);
assertEquals(Instant.parse("2000-01-01T00:00:00Z"), sample.getStartTime());
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
|
assertEquals(FraggleName.BOOBER, fraggle.getName());
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
assertEquals(Instant.parse("2000-01-01T00:00:00Z"), sample.getStartTime());
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
assertEquals(Instant.parse("2000-01-01T00:00:00Z"), sample.getStartTime());
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
assertTrue(muppeteer instanceof DaveGoelz);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
assertEquals(Date.from(Instant.parse("2001-01-01T00:00:00Z")), sample.getEndTime());
}
private void checkQueen(Gorg gorg) {
assertEquals("Queen", gorg.getName());
assertEquals(38, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
|
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
}
private void checkKing(Gorg gorg) {
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
|
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
assertEquals("King", gorg.getName());
assertEquals(42, (int) gorg.getAge());
assertTrue(gorg.getChild().isPresent());
gorg.getChild().ifPresent(this::checkJunior);
}
private void checkJunior(Gorg gorg) {
assertEquals("Junior", gorg.getName());
assertEquals(15, (int) gorg.getAge());
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
assertFalse(muppeteer instanceof KathrynMullen);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
assertFalse(gorg.getChild().isPresent());
}
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
assertTrue(muppeteer instanceof JerryNelson);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
private void checkBoober(Fraggle fraggle) {
assertEquals(FraggleName.BOOBER, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("clothes washer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof DaveGoelz);
assertEquals("Dave Goelz", muppeteer.getName());
assertEquals(9001, ((Boober) fraggle).getNumberOfSuperstitions());
assertFalse(fraggle.getRoommate().isPresent());
}
private void checkMokey(Fraggle fraggle) {
assertEquals(FraggleName.MOKEY, fraggle.getName());
assertEquals(11, (int) fraggle.getAge());
assertEquals("radish picker", fraggle.getJob());
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
|
assertEquals(20, ((Gobo) fraggle).getFetchedPostcards());
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
assertEquals(20, ((Gobo) fraggle).getFetchedPostcards());
Map map = ((Gobo) fraggle).getMap();
assertEquals(1, map.size());
assertEquals(4, ((Gobo) fraggle).getX());
assertEquals(123, map.get("abc"));
Optional<Fraggle> roommate = fraggle.getRoommate();
assertTrue(roommate.isPresent());
roommate.ifPresent(this::checkWembley);
}
private void checkWembley(Fraggle fraggle) {
assertEquals(FraggleName.WEMBLEY, fraggle.getName());
assertEquals(9, (int) fraggle.getAge());
assertEquals("fire truck siren", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
assertEquals(500, ((Mokey) fraggle).getRadishesPicked());
assertFalse(fraggle.getRoommate().isPresent());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
assertEquals(20, ((Gobo) fraggle).getFetchedPostcards());
Map map = ((Gobo) fraggle).getMap();
assertEquals(1, map.size());
assertEquals(4, ((Gobo) fraggle).getX());
assertEquals(123, map.get("abc"));
Optional<Fraggle> roommate = fraggle.getRoommate();
assertTrue(roommate.isPresent());
roommate.ifPresent(this::checkWembley);
}
private void checkWembley(Fraggle fraggle) {
assertEquals(FraggleName.WEMBLEY, fraggle.getName());
assertEquals(9, (int) fraggle.getAge());
assertEquals("fire truck siren", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
|
assertTrue(muppeteer instanceof SteveWhitmire);
|
peckb1/autojackson
|
examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
|
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
|
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
assertEquals(20, ((Gobo) fraggle).getFetchedPostcards());
Map map = ((Gobo) fraggle).getMap();
assertEquals(1, map.size());
assertEquals(4, ((Gobo) fraggle).getX());
assertEquals(123, map.get("abc"));
Optional<Fraggle> roommate = fraggle.getRoommate();
assertTrue(roommate.isPresent());
roommate.ifPresent(this::checkWembley);
}
private void checkWembley(Fraggle fraggle) {
assertEquals(FraggleName.WEMBLEY, fraggle.getName());
assertEquals(9, (int) fraggle.getAge());
assertEquals("fire truck siren", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof SteveWhitmire);
assertEquals("Steve Whitmire", muppeteer.getName());
|
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Boober.java
// @AutoJackson
// public interface Boober extends Fraggle<DaveGoelz> {
//
// @Named("superstitions") long getNumberOfSuperstitions();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Gobo.java
// @AutoJackson
// public interface Gobo<X extends Number> extends Fraggle<JerryNelson> {
//
// @Named("postcards") int getFetchedPostcards();
//
// X getX();
//
// @Named("zed") Map getMap() throws IOException;
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Mokey.java
// @AutoJackson
// public interface Mokey extends Fraggle {
//
// @Named("radishes") int getRadishesPicked();
//
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/DaveGoelz.java
// @AutoJackson
// public interface DaveGoelz extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/JerryNelson.java
// @AutoJackson
// public interface JerryNelson extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/KathrynMullen.java
// @AutoJackson
// public interface KathrynMullen extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/muppeteers/SteveWhitmire.java
// @AutoJackson
// public interface SteveWhitmire extends Muppeteer { }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/Fraggle.java
// enum FraggleName {
// GOBO(Gobo.class),
// MOKEY(Mokey.class),
// WEMBLEY(Wembley.class),
// BOOBER(Boober.class),
// RED(Red.class);
//
// private final Class<? extends Fraggle> fraggleClass;
//
// FraggleName(Class<? extends Fraggle> fraggleClass) {
// this.fraggleClass = fraggleClass;
// }
//
// @AutoJacksonTypeClass
// public Class<? extends Fraggle> getFraggleClass() {
// return fraggleClass;
// }
// }
//
// Path: examples/src/main/java/com/github/peckb1/examples/auto/fraggles/Wembley.java
// @AutoJackson
// public interface Wembley extends Fraggle<SteveWhitmire> {
//
// @Named("fires") int getNumberOfFiresPutOut();
//
// }
// Path: examples/src/test/java/com/github/peckb1/examples/auto/TestModel.java
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.github.peckb1.examples.auto.fraggles.Boober;
import com.github.peckb1.examples.auto.fraggles.Gobo;
import com.github.peckb1.examples.auto.fraggles.Mokey;
import com.github.peckb1.examples.auto.muppeteers.DaveGoelz;
import com.github.peckb1.examples.auto.muppeteers.JerryNelson;
import com.github.peckb1.examples.auto.muppeteers.KathrynMullen;
import com.github.peckb1.examples.auto.muppeteers.SteveWhitmire;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import peckb1.autojackson.AutoJacksonSetup;
import com.github.peckb1.examples.auto.Fraggle.FraggleName;
import com.github.peckb1.examples.auto.fraggles.Wembley;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Muppeteer muppeteer = fraggle.getMuppeteer();
assertFalse(muppeteer instanceof KathrynMullen);
assertEquals("Kathryn Mullen", muppeteer.getName());
}
private void checkGobo(Fraggle fraggle) throws IOException {
assertEquals(FraggleName.GOBO, fraggle.getName());
assertEquals(10, (int) fraggle.getAge());
assertEquals("singer", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof JerryNelson);
assertEquals("Jerry Nelson", muppeteer.getName());
assertEquals(20, ((Gobo) fraggle).getFetchedPostcards());
Map map = ((Gobo) fraggle).getMap();
assertEquals(1, map.size());
assertEquals(4, ((Gobo) fraggle).getX());
assertEquals(123, map.get("abc"));
Optional<Fraggle> roommate = fraggle.getRoommate();
assertTrue(roommate.isPresent());
roommate.ifPresent(this::checkWembley);
}
private void checkWembley(Fraggle fraggle) {
assertEquals(FraggleName.WEMBLEY, fraggle.getName());
assertEquals(9, (int) fraggle.getAge());
assertEquals("fire truck siren", fraggle.getJob());
Muppeteer muppeteer = fraggle.getMuppeteer();
assertTrue(muppeteer instanceof SteveWhitmire);
assertEquals("Steve Whitmire", muppeteer.getName());
|
assertEquals(15, ((Wembley) fraggle).getNumberOfFiresPutOut());
|
uzyovoys/aggregate
|
modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
|
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
|
package com.aggregate.dictation;
/**
* Created by morfeusys on 24.02.16.
*/
public class Dictation extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(Dictation.class);
private String osName;
@Override
public void start() throws Exception {
osName = System.getProperty("os.name").toLowerCase();
JsonObject config = config();
config.put("signal", "dictation");
config.put("key-codes", config.getJsonArray("key-codes", new JsonArray()));
vertx.eventBus().consumer("dictation.start", m -> startAction());
vertx.eventBus().consumer("dictation.stop", m -> stopAction());
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
// Path: modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
package com.aggregate.dictation;
/**
* Created by morfeusys on 24.02.16.
*/
public class Dictation extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(Dictation.class);
private String osName;
@Override
public void start() throws Exception {
osName = System.getProperty("os.name").toLowerCase();
JsonObject config = config();
config.put("signal", "dictation");
config.put("key-codes", config.getJsonArray("key-codes", new JsonArray()));
vertx.eventBus().consumer("dictation.start", m -> startAction());
vertx.eventBus().consumer("dictation.stop", m -> stopAction());
|
vertx.eventBus().consumer("cmd.dictation.type", m -> type(Request.fromMessage(m)));
|
uzyovoys/aggregate
|
modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
|
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
|
package com.aggregate.dictation;
/**
* Created by morfeusys on 24.02.16.
*/
public class Dictation extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(Dictation.class);
private String osName;
@Override
public void start() throws Exception {
osName = System.getProperty("os.name").toLowerCase();
JsonObject config = config();
config.put("signal", "dictation");
config.put("key-codes", config.getJsonArray("key-codes", new JsonArray()));
vertx.eventBus().consumer("dictation.start", m -> startAction());
vertx.eventBus().consumer("dictation.stop", m -> stopAction());
vertx.eventBus().consumer("cmd.dictation.type", m -> type(Request.fromMessage(m)));
vertx.eventBus().send("key.addKeyAction", config);
vertx.eventBus().consumer("mr.deployed", m -> {
if (m.body().toString().matches("(.*)key-detector")){
vertx.eventBus().send("key.addKeyAction", config);
}
});
}
private void type(Request request) {
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
// Path: modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
package com.aggregate.dictation;
/**
* Created by morfeusys on 24.02.16.
*/
public class Dictation extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(Dictation.class);
private String osName;
@Override
public void start() throws Exception {
osName = System.getProperty("os.name").toLowerCase();
JsonObject config = config();
config.put("signal", "dictation");
config.put("key-codes", config.getJsonArray("key-codes", new JsonArray()));
vertx.eventBus().consumer("dictation.start", m -> startAction());
vertx.eventBus().consumer("dictation.stop", m -> stopAction());
vertx.eventBus().consumer("cmd.dictation.type", m -> type(Request.fromMessage(m)));
vertx.eventBus().send("key.addKeyAction", config);
vertx.eventBus().consumer("mr.deployed", m -> {
if (m.body().toString().matches("(.*)key-detector")){
vertx.eventBus().send("key.addKeyAction", config);
}
});
}
private void type(Request request) {
|
String text = request.markup.get(Pattern.TEXT).source;
|
uzyovoys/aggregate
|
modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
|
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
|
vertx.eventBus().send("key.addKeyAction", config);
}
});
}
private void type(Request request) {
String text = request.markup.get(Pattern.TEXT).source;
if (!text.isEmpty()) {
type(text);
}
}
private void type(String text) {
try {
Robot robot = new Robot();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(text);
clipboard.setContents(stringSelection, stringSelection);
int ctrl = osName.contains("mac") ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
robot.keyPress(ctrl);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(ctrl);
} catch (Exception e) {
log.error("Cannot type", e);
}
}
private void startAction(){
vertx.eventBus().publish("asr.start", null);
|
// Path: api/java-api/src/main/java/com/aggregate/api/Pattern.java
// public class Pattern {
// public static final String TEXT = "Text";
// public static final String NUMBER = "Number";
// public static final String DATE = "Date";
// public static final String TIME = "Time";
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
// Path: modules/dictation/src/main/java/com/aggregate/dictation/Dictation.java
import com.aggregate.api.Pattern;
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
vertx.eventBus().send("key.addKeyAction", config);
}
});
}
private void type(Request request) {
String text = request.markup.get(Pattern.TEXT).source;
if (!text.isEmpty()) {
type(text);
}
}
private void type(String text) {
try {
Robot robot = new Robot();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(text);
clipboard.setContents(stringSelection, stringSelection);
int ctrl = osName.contains("mac") ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
robot.keyPress(ctrl);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(ctrl);
} catch (Exception e) {
log.error("Cannot type", e);
}
}
private void startAction(){
vertx.eventBus().publish("asr.start", null);
|
vertx.eventBus().send("response", new Response("dictation.text", true));
|
uzyovoys/aggregate
|
modules/dusi/src/main/java/com/aggregate/dusi/DusiAssistant.java
|
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
|
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.awt.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
|
package com.aggregate.dusi;
/**
* Created by morfeusys on 22.02.16.
*/
public class DusiAssistant extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(DusiAssistant.class);
private String id;
private WSClient wsClient;
@Override
public void start(Future<Void> f) throws Exception {
id = config().getString("id");
if (id == null || id.isEmpty()) {
f.fail("Please provide your dusi ID");
return;
}
vertx.eventBus().consumer("cmd.dusi", msg -> {
|
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
// Path: modules/dusi/src/main/java/com/aggregate/dusi/DusiAssistant.java
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.awt.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
package com.aggregate.dusi;
/**
* Created by morfeusys on 22.02.16.
*/
public class DusiAssistant extends AbstractVerticle {
private static Logger log = LoggerFactory.getLogger(DusiAssistant.class);
private String id;
private WSClient wsClient;
@Override
public void start(Future<Void> f) throws Exception {
id = config().getString("id");
if (id == null || id.isEmpty()) {
f.fail("Please provide your dusi ID");
return;
}
vertx.eventBus().consumer("cmd.dusi", msg -> {
|
process(Request.fromMessage(msg));
|
uzyovoys/aggregate
|
modules/dusi/src/main/java/com/aggregate/dusi/DusiAssistant.java
|
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
|
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.awt.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
|
} catch (InterruptedException e) {
h.fail(e);
}
}, true, r -> {
if (r.succeeded()) {
send(input);
} else {
log.error("Cannot connect");
}
});
} catch (Exception e) {
log.error("Cannot create ws client", e);
}
} else {
send(input);
}
}
private void send(String input) {
wsClient.send(input);
}
private void processReply(JsonObject json) {
String uri = json.getString("response_uri");
String text = json.getString("speech", json.getString("text"));
List<String> speeches = new ArrayList<>();
if (text != null) {
speeches.addAll(Arrays.asList(text.split("\\|")));
}
boolean modal = json.getBoolean("modal", false);
|
// Path: api/java-api/src/main/java/com/aggregate/api/Request.java
// public class Request {
// /**
// * Markup of input speech
// * @see Markup
// */
// public final Markup markup;
//
// public Request(Markup markup) {
// this.markup = markup;
// }
//
// /**
// * Converts this instance to Json object
// * @return JsonObject instance
// */
// public JsonObject toJson() {
// JsonObject json = new JsonObject();
// if (markup != null) {
// json.put("markup", markup.toJson());
// }
// return json;
// }
//
//
// /**
// * Converts Json object to Request instance
// * @param json JsonObject
// * @return Request instance
// */
// public static Request fromJson(JsonObject json) {
// return new Request(Markup.fromJson(json.getJsonObject("markup")));
// }
//
// /**
// * Converts Vertx's event message to Request instance
// * @param msg - Vertx's event message
// * @return Request instance
// * @see Message
// */
// public static Request fromMessage(Message msg) {
// Object body = msg.body();
// if (body instanceof JsonObject) {
// return fromJson((JsonObject) body);
// }
// return null;
// }
// }
//
// Path: api/java-api/src/main/java/com/aggregate/api/Response.java
// public class Response extends JsonObject {
// /**
// * List of output speech strings (could be empty)
// */
// public final List<String> speeches;
//
// /**
// * Dialog's context (optional)
// */
// public final String context;
//
// /**
// * If switching context is modal or not
// */
// public final boolean modal;
//
// public Response(String speech) {
// this(singletonList(speech));
// }
//
// public Response(List<String> speeches) {
// this(speeches, null, false);
// }
//
// public Response(String speech, String context, boolean modal) {
// this(singletonList(speech), context, modal);
// }
//
// public Response(String context, boolean modal) {
// this(emptyList(), context, modal);
// }
//
// public Response(List<String> speeches, String context, boolean modal) {
// this.speeches = unmodifiableList(speeches);
// this.context = context;
// this.modal = modal;
// JsonArray array = new JsonArray();
// speeches.forEach(s -> {
// if (s != null && !s.isEmpty()) array.add(s);
// });
// put("context", context);
// put("modal", modal);
// put("speeches", array);
// }
//
//
// /**
// * Converts Json object to Response instance
// * @param json JsonObject
// * @return Response instance
// */
// public static Response fromJson(JsonObject json) {
// JsonArray array = json.getJsonArray("speeches", new JsonArray());
// List<String> speeches = new ArrayList<>(array.size());
// array.forEach(s -> speeches.add(s.toString()));
// if (speeches.isEmpty()) {
// String speech = json.getString("speech");
// if (speech != null) speeches.add(speech);
// }
// String context = json.getString("context", json.getString("module"));
// Boolean modal = json.getBoolean("modal", false);
// return new Response(speeches, context, modal);
// }
// }
// Path: modules/dusi/src/main/java/com/aggregate/dusi/DusiAssistant.java
import com.aggregate.api.Request;
import com.aggregate.api.Response;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import org.java_websocket.WebSocket;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.awt.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
} catch (InterruptedException e) {
h.fail(e);
}
}, true, r -> {
if (r.succeeded()) {
send(input);
} else {
log.error("Cannot connect");
}
});
} catch (Exception e) {
log.error("Cannot create ws client", e);
}
} else {
send(input);
}
}
private void send(String input) {
wsClient.send(input);
}
private void processReply(JsonObject json) {
String uri = json.getString("response_uri");
String text = json.getString("speech", json.getString("text"));
List<String> speeches = new ArrayList<>();
if (text != null) {
speeches.addAll(Arrays.asList(text.split("\\|")));
}
boolean modal = json.getBoolean("modal", false);
|
vertx.eventBus().publish("response", new Response(speeches, modal ? "com.aggregate.dusi" : null, modal));
|
xoodle/frost
|
app/src/main/java/com/studentsearch/xoodle/studentsearch/adapter/SliderAdapter.java
|
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/StudentData.java
// public class StudentData implements Parcelable {
//
// @SerializedName("a")
// public String address;
//
// @SerializedName("b")
// public String bloodGroup;
//
// @SerializedName("d")
// public String dept;
//
// @SerializedName("g")
// public String gender;
//
// @SerializedName("h")
// public String hall;
//
// @SerializedName("i")
// public String rollNo;
//
// @SerializedName("n")
// public String name;
//
// @SerializedName("p")
// public String programme;
//
// @SerializedName("r")
// public String roomNo;
//
// @SerializedName("u")
// public String userName;
//
// public String year;
//
// public static final Parcelable.Creator<StudentData> CREATOR = new Parcelable.Creator<StudentData>() {
// public StudentData createFromParcel(Parcel in) {
// return new StudentData(in);
// }
//
// public StudentData[] newArray(int size) {
// return new StudentData[size];
// }
// };
//
// public StudentData(String address, String bloodGroup, String dept, String gender, String hall, String rollNo, String name, String programme, String roomNo, String userName) {
// this.address = address;
// this.bloodGroup = bloodGroup;
// this.dept = dept;
// this.gender = gender;
// this.hall = hall;
// this.rollNo = rollNo;
// this.name = name;
// this.programme = programme;
// this.roomNo = roomNo;
// this.userName = userName;
// setYear();
// }
//
// private StudentData(Parcel in) {
// // This order must match the order in writeToParcel()
// address = in.readString();
// bloodGroup = in.readString();
// dept = in.readString();
// gender = in.readString();
// hall = in.readString();
// rollNo = in.readString();
// name = in.readString();
// programme = in.readString();
// roomNo = in.readString();
// userName = in.readString();
// year = in.readString();
// }
//
// public void writeToParcel(Parcel out, int flags) {
// // Again this order must match the Question(Parcel) constructor
// out.writeString(address);
// out.writeString(bloodGroup);
// out.writeString(dept);
// out.writeString(gender);
// out.writeString(hall);
// out.writeString(rollNo);
// out.writeString(name);
// out.writeString(programme);
// out.writeString(roomNo);
// out.writeString(userName);
// out.writeString(getYear());
// }
//
// public int describeContents() {
// return 0;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getBloodGroup() {
// return bloodGroup;
// }
//
// public String getDept() {
// return dept;
// }
//
// public String getGender() {
// return gender;
// }
//
// public String getHall() {
// return hall;
// }
//
// public String getRollNo() {
// return rollNo;
// }
//
// public String getName() {
// return name;
// }
//
// public String getProgramme() {
// return programme;
// }
//
// public String getRoomNo() {
// return roomNo;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public void setBloodGroup(String bloodGroup) {
// this.bloodGroup = bloodGroup;
// }
//
// public void setDept(String dept) {
// this.dept = dept;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// public void setHall(String hall) {
// this.hall = hall;
// }
//
// public void setRollNo(String rollNo) {
// this.rollNo = rollNo;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setProgramme(String programme) {
// this.programme = programme;
// }
//
// public void setRoomNo(String roomNo) {
// this.roomNo = roomNo;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public void setYear() {
// year = "Y" + rollNo.substring(0, 2);
// }
// }
|
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.studentsearch.xoodle.studentsearch.R;
import com.studentsearch.xoodle.studentsearch.StudentData;
import java.util.ArrayList;
|
package com.studentsearch.xoodle.studentsearch.adapter;
/**
* Created by kaushal on 7/7/17.
*/
public class SliderAdapter extends RecyclerView.Adapter<SliderCard> {
private final int count;
private final View.OnClickListener listener;
private Context context;
|
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/StudentData.java
// public class StudentData implements Parcelable {
//
// @SerializedName("a")
// public String address;
//
// @SerializedName("b")
// public String bloodGroup;
//
// @SerializedName("d")
// public String dept;
//
// @SerializedName("g")
// public String gender;
//
// @SerializedName("h")
// public String hall;
//
// @SerializedName("i")
// public String rollNo;
//
// @SerializedName("n")
// public String name;
//
// @SerializedName("p")
// public String programme;
//
// @SerializedName("r")
// public String roomNo;
//
// @SerializedName("u")
// public String userName;
//
// public String year;
//
// public static final Parcelable.Creator<StudentData> CREATOR = new Parcelable.Creator<StudentData>() {
// public StudentData createFromParcel(Parcel in) {
// return new StudentData(in);
// }
//
// public StudentData[] newArray(int size) {
// return new StudentData[size];
// }
// };
//
// public StudentData(String address, String bloodGroup, String dept, String gender, String hall, String rollNo, String name, String programme, String roomNo, String userName) {
// this.address = address;
// this.bloodGroup = bloodGroup;
// this.dept = dept;
// this.gender = gender;
// this.hall = hall;
// this.rollNo = rollNo;
// this.name = name;
// this.programme = programme;
// this.roomNo = roomNo;
// this.userName = userName;
// setYear();
// }
//
// private StudentData(Parcel in) {
// // This order must match the order in writeToParcel()
// address = in.readString();
// bloodGroup = in.readString();
// dept = in.readString();
// gender = in.readString();
// hall = in.readString();
// rollNo = in.readString();
// name = in.readString();
// programme = in.readString();
// roomNo = in.readString();
// userName = in.readString();
// year = in.readString();
// }
//
// public void writeToParcel(Parcel out, int flags) {
// // Again this order must match the Question(Parcel) constructor
// out.writeString(address);
// out.writeString(bloodGroup);
// out.writeString(dept);
// out.writeString(gender);
// out.writeString(hall);
// out.writeString(rollNo);
// out.writeString(name);
// out.writeString(programme);
// out.writeString(roomNo);
// out.writeString(userName);
// out.writeString(getYear());
// }
//
// public int describeContents() {
// return 0;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getBloodGroup() {
// return bloodGroup;
// }
//
// public String getDept() {
// return dept;
// }
//
// public String getGender() {
// return gender;
// }
//
// public String getHall() {
// return hall;
// }
//
// public String getRollNo() {
// return rollNo;
// }
//
// public String getName() {
// return name;
// }
//
// public String getProgramme() {
// return programme;
// }
//
// public String getRoomNo() {
// return roomNo;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public void setBloodGroup(String bloodGroup) {
// this.bloodGroup = bloodGroup;
// }
//
// public void setDept(String dept) {
// this.dept = dept;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// public void setHall(String hall) {
// this.hall = hall;
// }
//
// public void setRollNo(String rollNo) {
// this.rollNo = rollNo;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setProgramme(String programme) {
// this.programme = programme;
// }
//
// public void setRoomNo(String roomNo) {
// this.roomNo = roomNo;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public void setYear() {
// year = "Y" + rollNo.substring(0, 2);
// }
// }
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/adapter/SliderAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.studentsearch.xoodle.studentsearch.R;
import com.studentsearch.xoodle.studentsearch.StudentData;
import java.util.ArrayList;
package com.studentsearch.xoodle.studentsearch.adapter;
/**
* Created by kaushal on 7/7/17.
*/
public class SliderAdapter extends RecyclerView.Adapter<SliderCard> {
private final int count;
private final View.OnClickListener listener;
private Context context;
|
private ArrayList<StudentData> studentList;
|
xoodle/frost
|
app/src/main/java/com/studentsearch/xoodle/studentsearch/database/DbHelper.java
|
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/StudentData.java
// public class StudentData implements Parcelable {
//
// @SerializedName("a")
// public String address;
//
// @SerializedName("b")
// public String bloodGroup;
//
// @SerializedName("d")
// public String dept;
//
// @SerializedName("g")
// public String gender;
//
// @SerializedName("h")
// public String hall;
//
// @SerializedName("i")
// public String rollNo;
//
// @SerializedName("n")
// public String name;
//
// @SerializedName("p")
// public String programme;
//
// @SerializedName("r")
// public String roomNo;
//
// @SerializedName("u")
// public String userName;
//
// public String year;
//
// public static final Parcelable.Creator<StudentData> CREATOR = new Parcelable.Creator<StudentData>() {
// public StudentData createFromParcel(Parcel in) {
// return new StudentData(in);
// }
//
// public StudentData[] newArray(int size) {
// return new StudentData[size];
// }
// };
//
// public StudentData(String address, String bloodGroup, String dept, String gender, String hall, String rollNo, String name, String programme, String roomNo, String userName) {
// this.address = address;
// this.bloodGroup = bloodGroup;
// this.dept = dept;
// this.gender = gender;
// this.hall = hall;
// this.rollNo = rollNo;
// this.name = name;
// this.programme = programme;
// this.roomNo = roomNo;
// this.userName = userName;
// setYear();
// }
//
// private StudentData(Parcel in) {
// // This order must match the order in writeToParcel()
// address = in.readString();
// bloodGroup = in.readString();
// dept = in.readString();
// gender = in.readString();
// hall = in.readString();
// rollNo = in.readString();
// name = in.readString();
// programme = in.readString();
// roomNo = in.readString();
// userName = in.readString();
// year = in.readString();
// }
//
// public void writeToParcel(Parcel out, int flags) {
// // Again this order must match the Question(Parcel) constructor
// out.writeString(address);
// out.writeString(bloodGroup);
// out.writeString(dept);
// out.writeString(gender);
// out.writeString(hall);
// out.writeString(rollNo);
// out.writeString(name);
// out.writeString(programme);
// out.writeString(roomNo);
// out.writeString(userName);
// out.writeString(getYear());
// }
//
// public int describeContents() {
// return 0;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getBloodGroup() {
// return bloodGroup;
// }
//
// public String getDept() {
// return dept;
// }
//
// public String getGender() {
// return gender;
// }
//
// public String getHall() {
// return hall;
// }
//
// public String getRollNo() {
// return rollNo;
// }
//
// public String getName() {
// return name;
// }
//
// public String getProgramme() {
// return programme;
// }
//
// public String getRoomNo() {
// return roomNo;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public void setBloodGroup(String bloodGroup) {
// this.bloodGroup = bloodGroup;
// }
//
// public void setDept(String dept) {
// this.dept = dept;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// public void setHall(String hall) {
// this.hall = hall;
// }
//
// public void setRollNo(String rollNo) {
// this.rollNo = rollNo;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setProgramme(String programme) {
// this.programme = programme;
// }
//
// public void setRoomNo(String roomNo) {
// this.roomNo = roomNo;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public void setYear() {
// year = "Y" + rollNo.substring(0, 2);
// }
// }
|
import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.studentsearch.xoodle.studentsearch.StudentData;
import java.io.Serializable;
import static android.R.attr.data;
|
+ COLUMN_PROGRAMME + " TEXT, "
+ COLUMN_USER_NAME + " TEXT, "
+ COLUMN_YEAR + " TEXT);";
private static final String DROP_TABLE_IF_EXISTS = "DROP TABLE IF EXISTS " + TABLE_NAME;
private DbHelper(Context context, String dbName, Integer version) {
super(context, dbName, null, version);
}
public static DbHelper getDbHelperInstance(Context context, String dbName, Integer version) {
if (dbHelper == null)
dbHelper = new DbHelper(context, dbName, version);
return dbHelper;
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_TABLE_IF_NOT_EXISTS);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(DROP_TABLE_IF_EXISTS);
}
|
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/StudentData.java
// public class StudentData implements Parcelable {
//
// @SerializedName("a")
// public String address;
//
// @SerializedName("b")
// public String bloodGroup;
//
// @SerializedName("d")
// public String dept;
//
// @SerializedName("g")
// public String gender;
//
// @SerializedName("h")
// public String hall;
//
// @SerializedName("i")
// public String rollNo;
//
// @SerializedName("n")
// public String name;
//
// @SerializedName("p")
// public String programme;
//
// @SerializedName("r")
// public String roomNo;
//
// @SerializedName("u")
// public String userName;
//
// public String year;
//
// public static final Parcelable.Creator<StudentData> CREATOR = new Parcelable.Creator<StudentData>() {
// public StudentData createFromParcel(Parcel in) {
// return new StudentData(in);
// }
//
// public StudentData[] newArray(int size) {
// return new StudentData[size];
// }
// };
//
// public StudentData(String address, String bloodGroup, String dept, String gender, String hall, String rollNo, String name, String programme, String roomNo, String userName) {
// this.address = address;
// this.bloodGroup = bloodGroup;
// this.dept = dept;
// this.gender = gender;
// this.hall = hall;
// this.rollNo = rollNo;
// this.name = name;
// this.programme = programme;
// this.roomNo = roomNo;
// this.userName = userName;
// setYear();
// }
//
// private StudentData(Parcel in) {
// // This order must match the order in writeToParcel()
// address = in.readString();
// bloodGroup = in.readString();
// dept = in.readString();
// gender = in.readString();
// hall = in.readString();
// rollNo = in.readString();
// name = in.readString();
// programme = in.readString();
// roomNo = in.readString();
// userName = in.readString();
// year = in.readString();
// }
//
// public void writeToParcel(Parcel out, int flags) {
// // Again this order must match the Question(Parcel) constructor
// out.writeString(address);
// out.writeString(bloodGroup);
// out.writeString(dept);
// out.writeString(gender);
// out.writeString(hall);
// out.writeString(rollNo);
// out.writeString(name);
// out.writeString(programme);
// out.writeString(roomNo);
// out.writeString(userName);
// out.writeString(getYear());
// }
//
// public int describeContents() {
// return 0;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getBloodGroup() {
// return bloodGroup;
// }
//
// public String getDept() {
// return dept;
// }
//
// public String getGender() {
// return gender;
// }
//
// public String getHall() {
// return hall;
// }
//
// public String getRollNo() {
// return rollNo;
// }
//
// public String getName() {
// return name;
// }
//
// public String getProgramme() {
// return programme;
// }
//
// public String getRoomNo() {
// return roomNo;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public String getYear() {
// return year;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public void setBloodGroup(String bloodGroup) {
// this.bloodGroup = bloodGroup;
// }
//
// public void setDept(String dept) {
// this.dept = dept;
// }
//
// public void setGender(String gender) {
// this.gender = gender;
// }
//
// public void setHall(String hall) {
// this.hall = hall;
// }
//
// public void setRollNo(String rollNo) {
// this.rollNo = rollNo;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public void setProgramme(String programme) {
// this.programme = programme;
// }
//
// public void setRoomNo(String roomNo) {
// this.roomNo = roomNo;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public void setYear() {
// year = "Y" + rollNo.substring(0, 2);
// }
// }
// Path: app/src/main/java/com/studentsearch/xoodle/studentsearch/database/DbHelper.java
import android.content.ContentValues;
import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.studentsearch.xoodle.studentsearch.StudentData;
import java.io.Serializable;
import static android.R.attr.data;
+ COLUMN_PROGRAMME + " TEXT, "
+ COLUMN_USER_NAME + " TEXT, "
+ COLUMN_YEAR + " TEXT);";
private static final String DROP_TABLE_IF_EXISTS = "DROP TABLE IF EXISTS " + TABLE_NAME;
private DbHelper(Context context, String dbName, Integer version) {
super(context, dbName, null, version);
}
public static DbHelper getDbHelperInstance(Context context, String dbName, Integer version) {
if (dbHelper == null)
dbHelper = new DbHelper(context, dbName, version);
return dbHelper;
}
@Override
public void onCreate(SQLiteDatabase db) {
try {
db.execSQL(CREATE_TABLE_IF_NOT_EXISTS);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(DROP_TABLE_IF_EXISTS);
}
|
public void insertStudents(StudentData[] students) {
|
nhatminhle/cofoja
|
src/com/google/java/contract/core/apt/FactoryUtils.java
|
// Path: src/com/google/java/contract/core/model/ElementKind.java
// public enum ElementKind {
// /*
// * Source elements.
// */
//
// /**
// * A source file.
// */
// SOURCE,
//
// /**
// * A class.
// */
// CLASS,
//
// /**
// * An interface.
// */
// INTERFACE,
//
// /**
// * An annotation.
// */
// ANNOTATION_TYPE,
//
// /**
// * An enum.
// */
// ENUM,
//
// /**
// * An enum constant.
// */
// CONSTANT,
//
// /**
// * A field. Mocked in output.
// */
// FIELD,
//
// /**
// * A method that is not a constructor. Mocked in output.
// */
// METHOD,
//
// /**
// * A constructor. Mocked in output.
// */
// CONSTRUCTOR,
//
// /**
// * A method parameter.
// */
// PARAMETER,
//
// /**
// * An @Invariant annotation.
// */
// INVARIANT,
//
// /**
// * An @Requires annotation. Source-only, not present in output.
// */
// REQUIRES,
//
// /**
// * An @Ensures annotation. Source-only, not present in output.
// */
// ENSURES,
//
// /**
// * An @ThrowEnsures annotation. Source-only, not present in output.
// */
// THROW_ENSURES,
//
// /*
// * Output elements.
// */
//
// /**
// * An @ContractMethodSignature annotation.
// */
// CONTRACT_SIGNATURE,
//
// /**
// * A contract method.
// */
// CONTRACT_METHOD,
//
// /**
// * A mock contract method.
// */
// CONTRACT_MOCK;
//
// public boolean isType() {
// switch (this) {
// case CLASS:
// case ENUM:
// case INTERFACE:
// case ANNOTATION_TYPE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isMember() {
// switch (this) {
// case FIELD:
// case METHOD:
// case CONSTRUCTOR:
// case CONTRACT_METHOD:
// case CONTRACT_MOCK:
// return true;
// default:
// return false;
// }
// }
//
// @Requires("isMember()")
// public boolean isMock() {
// switch (this) {
// case METHOD:
// case CONSTRUCTOR:
// case CONTRACT_MOCK:
// return true;
// default:
// return false;
// }
// }
//
// @Requires("isMember()")
// public boolean isContract() {
// return !isMock();
// }
//
// public boolean isAnnotation() {
// switch (this) {
// case INVARIANT:
// case REQUIRES:
// case ENSURES:
// case THROW_ENSURES:
// case CONTRACT_SIGNATURE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isInterfaceType() {
// switch(this) {
// case INTERFACE:
// case ANNOTATION_TYPE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isSourceAnnotation() {
// switch (this) {
// case INVARIANT:
// case REQUIRES:
// case ENSURES:
// case THROW_ENSURES:
// return true;
// default:
// return false;
// }
// }
// }
|
import com.google.java.contract.Ensures;
import com.google.java.contract.Invariant;
import com.google.java.contract.Requires;
import com.google.java.contract.core.model.ClassName;
import com.google.java.contract.core.model.ElementKind;
import com.google.java.contract.core.model.ElementModifier;
import com.google.java.contract.core.model.QualifiedElementModel;
import com.google.java.contract.core.model.TypeName;
import java.util.Iterator;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
|
List<? extends TypeMirror> bounds = element.getBounds();
if (bounds.isEmpty()
|| (bounds.size() == 1
&& bounds.get(0).toString().equals("java.lang.Object"))) {
return new TypeName(name);
}
StringBuilder buffer = new StringBuilder();
buffer.append(name);
buffer.append(" extends ");
Iterator<? extends TypeMirror> iter = bounds.iterator();
for (;;) {
buffer.append(iter.next().toString());
if (!iter.hasNext()) {
break;
}
buffer.append(" & ");
}
return new TypeName(buffer.toString());
}
/**
* Gets the contract kind of an annotation given its qualified name.
* Returns null if the annotation is not a contract annotation.
*
* @param annotationName the fully qualified name of the annotation
* @return the contract type, null if not contracts
*/
|
// Path: src/com/google/java/contract/core/model/ElementKind.java
// public enum ElementKind {
// /*
// * Source elements.
// */
//
// /**
// * A source file.
// */
// SOURCE,
//
// /**
// * A class.
// */
// CLASS,
//
// /**
// * An interface.
// */
// INTERFACE,
//
// /**
// * An annotation.
// */
// ANNOTATION_TYPE,
//
// /**
// * An enum.
// */
// ENUM,
//
// /**
// * An enum constant.
// */
// CONSTANT,
//
// /**
// * A field. Mocked in output.
// */
// FIELD,
//
// /**
// * A method that is not a constructor. Mocked in output.
// */
// METHOD,
//
// /**
// * A constructor. Mocked in output.
// */
// CONSTRUCTOR,
//
// /**
// * A method parameter.
// */
// PARAMETER,
//
// /**
// * An @Invariant annotation.
// */
// INVARIANT,
//
// /**
// * An @Requires annotation. Source-only, not present in output.
// */
// REQUIRES,
//
// /**
// * An @Ensures annotation. Source-only, not present in output.
// */
// ENSURES,
//
// /**
// * An @ThrowEnsures annotation. Source-only, not present in output.
// */
// THROW_ENSURES,
//
// /*
// * Output elements.
// */
//
// /**
// * An @ContractMethodSignature annotation.
// */
// CONTRACT_SIGNATURE,
//
// /**
// * A contract method.
// */
// CONTRACT_METHOD,
//
// /**
// * A mock contract method.
// */
// CONTRACT_MOCK;
//
// public boolean isType() {
// switch (this) {
// case CLASS:
// case ENUM:
// case INTERFACE:
// case ANNOTATION_TYPE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isMember() {
// switch (this) {
// case FIELD:
// case METHOD:
// case CONSTRUCTOR:
// case CONTRACT_METHOD:
// case CONTRACT_MOCK:
// return true;
// default:
// return false;
// }
// }
//
// @Requires("isMember()")
// public boolean isMock() {
// switch (this) {
// case METHOD:
// case CONSTRUCTOR:
// case CONTRACT_MOCK:
// return true;
// default:
// return false;
// }
// }
//
// @Requires("isMember()")
// public boolean isContract() {
// return !isMock();
// }
//
// public boolean isAnnotation() {
// switch (this) {
// case INVARIANT:
// case REQUIRES:
// case ENSURES:
// case THROW_ENSURES:
// case CONTRACT_SIGNATURE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isInterfaceType() {
// switch(this) {
// case INTERFACE:
// case ANNOTATION_TYPE:
// return true;
// default:
// return false;
// }
// }
//
// public boolean isSourceAnnotation() {
// switch (this) {
// case INVARIANT:
// case REQUIRES:
// case ENSURES:
// case THROW_ENSURES:
// return true;
// default:
// return false;
// }
// }
// }
// Path: src/com/google/java/contract/core/apt/FactoryUtils.java
import com.google.java.contract.Ensures;
import com.google.java.contract.Invariant;
import com.google.java.contract.Requires;
import com.google.java.contract.core.model.ClassName;
import com.google.java.contract.core.model.ElementKind;
import com.google.java.contract.core.model.ElementModifier;
import com.google.java.contract.core.model.QualifiedElementModel;
import com.google.java.contract.core.model.TypeName;
import java.util.Iterator;
import java.util.List;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
List<? extends TypeMirror> bounds = element.getBounds();
if (bounds.isEmpty()
|| (bounds.size() == 1
&& bounds.get(0).toString().equals("java.lang.Object"))) {
return new TypeName(name);
}
StringBuilder buffer = new StringBuilder();
buffer.append(name);
buffer.append(" extends ");
Iterator<? extends TypeMirror> iter = bounds.iterator();
for (;;) {
buffer.append(iter.next().toString());
if (!iter.hasNext()) {
break;
}
buffer.append(" & ");
}
return new TypeName(buffer.toString());
}
/**
* Gets the contract kind of an annotation given its qualified name.
* Returns null if the annotation is not a contract annotation.
*
* @param annotationName the fully qualified name of the annotation
* @return the contract type, null if not contracts
*/
|
ElementKind getAnnotationKindForName(AnnotationMirror annotation) {
|
nhatminhle/cofoja
|
test/com/google/java/contract/tests/StackTest.java
|
// Path: test/com/google/java/contract/examples/ArrayListStack.java
// @Invariant("elements != null")
// public class ArrayListStack<T> implements Stack<T> {
// protected ArrayList<T> elements;
//
// public ArrayListStack() {
// elements = new ArrayList<T>();
// }
//
// @Override
// public int size() {
// return elements.size();
// }
//
// @Override
// public T peek() {
// return elements.get(elements.size() - 1);
// }
//
// @Override
// public T pop() {
// return elements.remove(elements.size() - 1);
// }
//
// @Override
// @Ensures("elements.contains(old (obj))")
// public void push(T obj) {
// elements.add(obj);
// }
// }
//
// Path: test/com/google/java/contract/examples/Stack.java
// @Invariant("size() >= 0")
// public interface Stack<T> {
// /**
// * Returns the number of elements in this stack.
// */
// public int size();
//
// /**
// * Returns the topmost element of this stack without removing it.
// */
// @Requires("size() >= 1")
// public T peek();
//
// /**
// * Pops the topmost element off this stack.
// */
// @Requires("size() >= 1")
// @Ensures({
// "size() == old (size()) - 1",
// "result == old (peek())"
// })
// public T pop();
//
// /**
// * Pushes an element onto the stack.
// */
// @Ensures({
// "size() == old (size()) + 1",
// "peek() == old (obj)"
// })
// public void push(T obj);
// }
|
import com.google.java.contract.InvariantError;
import com.google.java.contract.PostconditionError;
import com.google.java.contract.PreconditionError;
import com.google.java.contract.examples.ArrayListStack;
import com.google.java.contract.examples.Stack;
import junit.framework.TestCase;
|
/**
* A stack implementation that simply stores the last element. This
* implementation suffices to fool our contracts.
*/
public static class BogusLastElementStack<T>
extends BogusCountingStack<T> {
protected T lastElement;
@Override
public T peek() {
return lastElement;
}
@Override
public T pop() {
--count;
return lastElement;
}
@Override
public void push(T obj) {
++count;
lastElement = obj;
}
}
private Stack<Integer> stack;
@Override
public void setUp() {
|
// Path: test/com/google/java/contract/examples/ArrayListStack.java
// @Invariant("elements != null")
// public class ArrayListStack<T> implements Stack<T> {
// protected ArrayList<T> elements;
//
// public ArrayListStack() {
// elements = new ArrayList<T>();
// }
//
// @Override
// public int size() {
// return elements.size();
// }
//
// @Override
// public T peek() {
// return elements.get(elements.size() - 1);
// }
//
// @Override
// public T pop() {
// return elements.remove(elements.size() - 1);
// }
//
// @Override
// @Ensures("elements.contains(old (obj))")
// public void push(T obj) {
// elements.add(obj);
// }
// }
//
// Path: test/com/google/java/contract/examples/Stack.java
// @Invariant("size() >= 0")
// public interface Stack<T> {
// /**
// * Returns the number of elements in this stack.
// */
// public int size();
//
// /**
// * Returns the topmost element of this stack without removing it.
// */
// @Requires("size() >= 1")
// public T peek();
//
// /**
// * Pops the topmost element off this stack.
// */
// @Requires("size() >= 1")
// @Ensures({
// "size() == old (size()) - 1",
// "result == old (peek())"
// })
// public T pop();
//
// /**
// * Pushes an element onto the stack.
// */
// @Ensures({
// "size() == old (size()) + 1",
// "peek() == old (obj)"
// })
// public void push(T obj);
// }
// Path: test/com/google/java/contract/tests/StackTest.java
import com.google.java.contract.InvariantError;
import com.google.java.contract.PostconditionError;
import com.google.java.contract.PreconditionError;
import com.google.java.contract.examples.ArrayListStack;
import com.google.java.contract.examples.Stack;
import junit.framework.TestCase;
/**
* A stack implementation that simply stores the last element. This
* implementation suffices to fool our contracts.
*/
public static class BogusLastElementStack<T>
extends BogusCountingStack<T> {
protected T lastElement;
@Override
public T peek() {
return lastElement;
}
@Override
public T pop() {
--count;
return lastElement;
}
@Override
public void push(T obj) {
++count;
lastElement = obj;
}
}
private Stack<Integer> stack;
@Override
public void setUp() {
|
stack = new ArrayListStack<Integer>();
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/DuplicateEntityException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an entity already existed in it's parent.
*/
public final class DuplicateEntityException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DuplicateEntityException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/DuplicateEntityException.java
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an entity already existed in it's parent.
*/
public final class DuplicateEntityException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DuplicateEntityException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-DUPLICATE_ENTITY";
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityNotFoundExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
|
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link EntityNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class EntityNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityNotFoundExceptionTest.java
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link EntityNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class EntityNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final EntityNotFoundException original = new EntityNotFoundException(new EntityIdPath(new AId(1L)), new BId(1));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityNotFoundExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
|
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link EntityNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class EntityNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityNotFoundExceptionTest.java
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link EntityNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class EntityNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final EntityNotFoundException original = new EntityNotFoundException(new EntityIdPath(new AId(1L)), new BId(1));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityIdConverterTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import org.fuin.ddd4j.test.AId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
|
// TEST & VERIFY
testee.requireArgValid("a", null);
testee.requireArgValid("x", "A 1");
try {
testee.requireArgValid("a", "X 1");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: 'X 1'");
}
try {
testee.requireArgValid("a", "");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: ''");
}
}
@Test
public void testToVO() {
// PREPARE
final EntityIdConverter testee = new EntityIdConverter(new MyIdFactory());
final EntityId entityId = testee.toVO("A 1");
// TEST & VERIFY
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityIdConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import org.fuin.ddd4j.test.AId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
// TEST & VERIFY
testee.requireArgValid("a", null);
testee.requireArgValid("x", "A 1");
try {
testee.requireArgValid("a", "X 1");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: 'X 1'");
}
try {
testee.requireArgValid("a", "");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: ''");
}
}
@Test
public void testToVO() {
// PREPARE
final EntityIdConverter testee = new EntityIdConverter(new MyIdFactory());
final EntityId entityId = testee.toVO("A 1");
// TEST & VERIFY
|
assertThat(entityId).isInstanceOf(AId.class);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorKey.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/BusinessKey.java
// public interface BusinessKey extends Serializable {
//
// }
|
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.BusinessKey;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.ui.Label;
import org.fuin.objects4j.ui.ShortLabel;
import org.fuin.objects4j.ui.Tooltip;
import org.fuin.objects4j.vo.AbstractStringValueObject;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* A vendor's human readable business key.
*/
@Label(value = "Vendor number")
@ShortLabel(value = "VN")
@Tooltip("A human readable unique identifier for a vendor. " + "Used for example in mails or contracts as a reference.")
@Immutable
@XmlJavaTypeAdapter(VendorKeyConverter.class)
|
// Path: src/main/java/org/fuin/ddd4j/ddd/BusinessKey.java
// public interface BusinessKey extends Serializable {
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorKey.java
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.BusinessKey;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.ui.Label;
import org.fuin.objects4j.ui.ShortLabel;
import org.fuin.objects4j.ui.Tooltip;
import org.fuin.objects4j.vo.AbstractStringValueObject;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* A vendor's human readable business key.
*/
@Label(value = "Vendor number")
@ShortLabel(value = "VN")
@Tooltip("A human readable unique identifier for a vendor. " + "Used for example in mails or contracts as a reference.")
@Immutable
@XmlJavaTypeAdapter(VendorKeyConverter.class)
|
public final class VendorKey extends AbstractStringValueObject implements BusinessKey {
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/EncryptionKeyIdUnknownException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the encryption key identifier is unknown.
*/
public final class EncryptionKeyIdUnknownException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EncryptionKeyIdUnknownException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/EncryptionKeyIdUnknownException.java
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the encryption key identifier is unknown.
*/
public final class EncryptionKeyIdUnknownException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EncryptionKeyIdUnknownException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-ENCRYPTION_KEY_ID_UNKNOWN";
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/AggregateDeletedException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an aggregate of a given type and identifier was deleted from the repository.
*/
public final class AggregateDeletedException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateDeletedException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateDeletedException.java
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an aggregate of a given type and identifier was deleted from the repository.
*/
public final class AggregateDeletedException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateDeletedException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-AGGREGATE_DELETED";
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AggregateVersionConflictExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateVersionConflictException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateVersionConflictExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AggregateVersionConflictExceptionTest.java
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateVersionConflictException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateVersionConflictExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final VendorId vendorId = new VendorId(UUID.fromString("4dcf4c2c-10e1-4db9-ba9e-d1e644e9d119"));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/CEntity.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AbstractEntity.java
// public abstract class AbstractEntity<ROOT_ID extends AggregateRootId, ROOT extends AbstractAggregateRoot<ROOT_ID>, ID extends EntityId>
// implements Entity<ID> {
// // CHECKSTYLE:ON:LineLength
//
// private final ROOT root;
//
// /**
// * Constructor with root aggregate.
// *
// * @param root
// * Root aggregate.
// */
// public AbstractEntity(@NotNull final ROOT root) {
// super();
// Contract.requireArgNotNull("root", root);
// this.root = root;
// }
//
// /**
// * Applies the given new event. CAUTION: Don't use this method for applying historic events!
// *
// * @param event
// * Event to dispatch to the appropriate event handler method.
// */
// protected final void apply(@NotNull final DomainEvent<?> event) {
// root.applyNewChildEvent(this, event);
// }
//
// @Override
// public final int hashCode() {
// final int prime = 31;
// int result = 1;
// result = (prime * result) + getId().hashCode();
// return result;
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AbstractEntity<?, ?, ?> other = (AbstractEntity<?, ?, ?>) obj;
// if (!getId().equals(other.getId())) {
// return false;
// }
// return true;
// }
//
// /**
// * Returns the aggregate root the entity belongs to.
// *
// * @return Aggregate root this is a child of.
// */
// protected final ROOT getRoot() {
// return root;
// }
//
// /**
// * Returns the identifier of the aggregate root the entity belongs to.
// *
// * @return Unique aggregate root identifier.
// */
// protected final ROOT_ID getRootId() {
// return root.getId();
// }
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
|
import org.fuin.ddd4j.ddd.AbstractEntity;
import org.fuin.ddd4j.ddd.ApplyEvent;
import org.fuin.ddd4j.ddd.EntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
// CHECKSTYLE:OFF
public final class CEntity extends AbstractEntity<AId, ARoot, CId> {
private final BId parentId;
private final CId id;
private CEvent lastEvent;
public CEntity(final ARoot root, final BId parentId, final CId id) {
super(root);
this.parentId = parentId;
this.id = id;
}
@Override
public CId getId() {
return id;
}
@Override
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AbstractEntity.java
// public abstract class AbstractEntity<ROOT_ID extends AggregateRootId, ROOT extends AbstractAggregateRoot<ROOT_ID>, ID extends EntityId>
// implements Entity<ID> {
// // CHECKSTYLE:ON:LineLength
//
// private final ROOT root;
//
// /**
// * Constructor with root aggregate.
// *
// * @param root
// * Root aggregate.
// */
// public AbstractEntity(@NotNull final ROOT root) {
// super();
// Contract.requireArgNotNull("root", root);
// this.root = root;
// }
//
// /**
// * Applies the given new event. CAUTION: Don't use this method for applying historic events!
// *
// * @param event
// * Event to dispatch to the appropriate event handler method.
// */
// protected final void apply(@NotNull final DomainEvent<?> event) {
// root.applyNewChildEvent(this, event);
// }
//
// @Override
// public final int hashCode() {
// final int prime = 31;
// int result = 1;
// result = (prime * result) + getId().hashCode();
// return result;
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AbstractEntity<?, ?, ?> other = (AbstractEntity<?, ?, ?>) obj;
// if (!getId().equals(other.getId())) {
// return false;
// }
// return true;
// }
//
// /**
// * Returns the aggregate root the entity belongs to.
// *
// * @return Aggregate root this is a child of.
// */
// protected final ROOT getRoot() {
// return root;
// }
//
// /**
// * Returns the identifier of the aggregate root the entity belongs to.
// *
// * @return Unique aggregate root identifier.
// */
// protected final ROOT_ID getRootId() {
// return root.getId();
// }
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/CEntity.java
import org.fuin.ddd4j.ddd.AbstractEntity;
import org.fuin.ddd4j.ddd.ApplyEvent;
import org.fuin.ddd4j.ddd.EntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
// CHECKSTYLE:OFF
public final class CEntity extends AbstractEntity<AId, ARoot, CId> {
private final BId parentId;
private final CId id;
private CEvent lastEvent;
public CEntity(final ARoot root, final BId parentId, final CId id) {
super(root);
this.parentId = parentId;
this.id = id;
}
@Override
public CId getId() {
return id;
}
@Override
|
public EntityType getType() {
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AggregateVersionNotFoundExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateVersionNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateVersionNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AggregateVersionNotFoundExceptionTest.java
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateVersionNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateVersionNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final VendorId vendorId = new VendorId(UUID.fromString("4dcf4c2c-10e1-4db9-ba9e-d1e644e9d119"));
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/AggregateVersionNotFoundException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the requested version for an aggregate does not exist.
*/
public final class AggregateVersionNotFoundException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateVersionNotFoundException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateVersionNotFoundException.java
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the requested version for an aggregate does not exist.
*/
public final class AggregateVersionNotFoundException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateVersionNotFoundException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-AGGREGATE_VERSION_NOT_FOUND";
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/AId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class AId implements ImplRootId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class AId implements ImplRootId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("A");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/AId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class AId implements ImplRootId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class AId implements ImplRootId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("A");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/Person.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AbstractEntity.java
// public abstract class AbstractEntity<ROOT_ID extends AggregateRootId, ROOT extends AbstractAggregateRoot<ROOT_ID>, ID extends EntityId>
// implements Entity<ID> {
// // CHECKSTYLE:ON:LineLength
//
// private final ROOT root;
//
// /**
// * Constructor with root aggregate.
// *
// * @param root
// * Root aggregate.
// */
// public AbstractEntity(@NotNull final ROOT root) {
// super();
// Contract.requireArgNotNull("root", root);
// this.root = root;
// }
//
// /**
// * Applies the given new event. CAUTION: Don't use this method for applying historic events!
// *
// * @param event
// * Event to dispatch to the appropriate event handler method.
// */
// protected final void apply(@NotNull final DomainEvent<?> event) {
// root.applyNewChildEvent(this, event);
// }
//
// @Override
// public final int hashCode() {
// final int prime = 31;
// int result = 1;
// result = (prime * result) + getId().hashCode();
// return result;
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AbstractEntity<?, ?, ?> other = (AbstractEntity<?, ?, ?>) obj;
// if (!getId().equals(other.getId())) {
// return false;
// }
// return true;
// }
//
// /**
// * Returns the aggregate root the entity belongs to.
// *
// * @return Aggregate root this is a child of.
// */
// protected final ROOT getRoot() {
// return root;
// }
//
// /**
// * Returns the identifier of the aggregate root the entity belongs to.
// *
// * @return Unique aggregate root identifier.
// */
// protected final ROOT_ID getRootId() {
// return root.getId();
// }
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
|
import jakarta.validation.constraints.NotNull;
import org.fuin.ddd4j.ddd.AbstractEntity;
import org.fuin.ddd4j.ddd.ApplyEvent;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.objects4j.common.Contract;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Person entity.
*/
public class Person extends AbstractEntity<VendorId, Vendor, PersonId> {
private PersonId id;
private PersonName name;
/**
* Constructor with all data.
*
* @param vendor
* Aggregate root.
* @param id
* Unique identifier.
* @param name
* Name.
*/
public Person(@NotNull final Vendor vendor, final PersonId id, @NotNull final PersonName name) {
super(vendor);
// CHECK PRECONDITIONS
Contract.requireArgNotNull("vendor", vendor);
Contract.requireArgNotNull("id", id);
Contract.requireArgNotNull("name", name);
// NO EVENT HERE! THE EVENT FOR CONSTRUCTION IS
// ALWAYS FIRED BY THE PARENT ENTITY
this.id = id;
this.name = name;
}
/**
* Changes the name.
*
* @param newName
* New name.
*/
public final void changeName(@NotNull final PersonName newName) {
// CHECK PRECONDITIONS
Contract.requireArgNotNull("newName", newName);
// VERIFY BUSINESS RULES
// Nothing to do
// HANDLE EVENT
apply(new PersonNameChangedEvent(getRoot().getRef(), id, name, newName));
}
@ApplyEvent
private final void applyEvent(final PersonNameChangedEvent event) {
this.name = event.getNewName();
}
@Override
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AbstractEntity.java
// public abstract class AbstractEntity<ROOT_ID extends AggregateRootId, ROOT extends AbstractAggregateRoot<ROOT_ID>, ID extends EntityId>
// implements Entity<ID> {
// // CHECKSTYLE:ON:LineLength
//
// private final ROOT root;
//
// /**
// * Constructor with root aggregate.
// *
// * @param root
// * Root aggregate.
// */
// public AbstractEntity(@NotNull final ROOT root) {
// super();
// Contract.requireArgNotNull("root", root);
// this.root = root;
// }
//
// /**
// * Applies the given new event. CAUTION: Don't use this method for applying historic events!
// *
// * @param event
// * Event to dispatch to the appropriate event handler method.
// */
// protected final void apply(@NotNull final DomainEvent<?> event) {
// root.applyNewChildEvent(this, event);
// }
//
// @Override
// public final int hashCode() {
// final int prime = 31;
// int result = 1;
// result = (prime * result) + getId().hashCode();
// return result;
// }
//
// @Override
// public final boolean equals(final Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final AbstractEntity<?, ?, ?> other = (AbstractEntity<?, ?, ?>) obj;
// if (!getId().equals(other.getId())) {
// return false;
// }
// return true;
// }
//
// /**
// * Returns the aggregate root the entity belongs to.
// *
// * @return Aggregate root this is a child of.
// */
// protected final ROOT getRoot() {
// return root;
// }
//
// /**
// * Returns the identifier of the aggregate root the entity belongs to.
// *
// * @return Unique aggregate root identifier.
// */
// protected final ROOT_ID getRootId() {
// return root.getId();
// }
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/Person.java
import jakarta.validation.constraints.NotNull;
import org.fuin.ddd4j.ddd.AbstractEntity;
import org.fuin.ddd4j.ddd.ApplyEvent;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.objects4j.common.Contract;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Person entity.
*/
public class Person extends AbstractEntity<VendorId, Vendor, PersonId> {
private PersonId id;
private PersonName name;
/**
* Constructor with all data.
*
* @param vendor
* Aggregate root.
* @param id
* Unique identifier.
* @param name
* Name.
*/
public Person(@NotNull final Vendor vendor, final PersonId id, @NotNull final PersonName name) {
super(vendor);
// CHECK PRECONDITIONS
Contract.requireArgNotNull("vendor", vendor);
Contract.requireArgNotNull("id", id);
Contract.requireArgNotNull("name", name);
// NO EVENT HERE! THE EVENT FOR CONSTRUCTION IS
// ALWAYS FIRED BY THE PARENT ENTITY
this.id = id;
this.name = name;
}
/**
* Changes the name.
*
* @param newName
* New name.
*/
public final void changeName(@NotNull final PersonName newName) {
// CHECK PRECONDITIONS
Contract.requireArgNotNull("newName", newName);
// VERIFY BUSINESS RULES
// Nothing to do
// HANDLE EVENT
apply(new PersonNameChangedEvent(getRoot().getRef(), id, name, newName));
}
@ApplyEvent
private final void applyEvent(final PersonNameChangedEvent event) {
this.name = event.getNewName();
}
@Override
|
public final EntityType getType() {
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorExampleTest.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/DomainEvent.java
// public interface DomainEvent<ID extends EntityId> extends Event {
//
// /**
// * Returns the path to the originator of the event.
// *
// * @return List of unique identifiers from aggregate root to the entity that emitted the event.
// */
// @NotNull
// public EntityIdPath getEntityIdPath();
//
// /**
// * Returns the identifier of the entity that caused this event. This is the last ID in the path.
// *
// * @return Entity identifier.
// */
// @NotNull
// public ID getEntityId();
//
// /**
// * Returns the version of the aggregate the entity belongs to.
// *
// * @return Aggregate version at the time the event was raised.
// */
// @Nullable
// public AggregateVersion getAggregateVersion();
//
// /**
// * Returns the aggregate version as integer. This is a null-safe shortcut for <code>getAggregateVersion().asBaseType()</code>-
// *
// * @return Expected version or {@literal null}.
// */
// @Nullable
// public Integer getAggregateVersionInteger();
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/Vendor.java
// public interface ConstructorService {
//
// /**
// * Adds a new vendor key to the context. The key will be persisted or an exception will be thrown if it already exists.
// *
// * @param key
// * Key to verify and persist.
// *
// * @throws DuplicateVendorKeyException
// * The given key already exists.
// */
// public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException;
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.UUID;
import org.fuin.ddd4j.ddd.DomainEvent;
import org.fuin.ddd4j.test.Vendor.ConstructorService;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class VendorExampleTest {
@Test
public void testConstructor() throws DuplicateVendorKeyException {
// PREPARE
VendorId id = new VendorId(UUID.randomUUID());
VendorKey key = new VendorKey("V00001");
VendorName name = new VendorName("Peter Parker Inc.");
|
// Path: src/main/java/org/fuin/ddd4j/ddd/DomainEvent.java
// public interface DomainEvent<ID extends EntityId> extends Event {
//
// /**
// * Returns the path to the originator of the event.
// *
// * @return List of unique identifiers from aggregate root to the entity that emitted the event.
// */
// @NotNull
// public EntityIdPath getEntityIdPath();
//
// /**
// * Returns the identifier of the entity that caused this event. This is the last ID in the path.
// *
// * @return Entity identifier.
// */
// @NotNull
// public ID getEntityId();
//
// /**
// * Returns the version of the aggregate the entity belongs to.
// *
// * @return Aggregate version at the time the event was raised.
// */
// @Nullable
// public AggregateVersion getAggregateVersion();
//
// /**
// * Returns the aggregate version as integer. This is a null-safe shortcut for <code>getAggregateVersion().asBaseType()</code>-
// *
// * @return Expected version or {@literal null}.
// */
// @Nullable
// public Integer getAggregateVersionInteger();
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/Vendor.java
// public interface ConstructorService {
//
// /**
// * Adds a new vendor key to the context. The key will be persisted or an exception will be thrown if it already exists.
// *
// * @param key
// * Key to verify and persist.
// *
// * @throws DuplicateVendorKeyException
// * The given key already exists.
// */
// public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException;
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorExampleTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.UUID;
import org.fuin.ddd4j.ddd.DomainEvent;
import org.fuin.ddd4j.test.Vendor.ConstructorService;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class VendorExampleTest {
@Test
public void testConstructor() throws DuplicateVendorKeyException {
// PREPARE
VendorId id = new VendorId(UUID.randomUUID());
VendorKey key = new VendorKey("V00001");
VendorName name = new VendorName("Peter Parker Inc.");
|
ConstructorService service = new ConstructorService() {
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorExampleTest.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/DomainEvent.java
// public interface DomainEvent<ID extends EntityId> extends Event {
//
// /**
// * Returns the path to the originator of the event.
// *
// * @return List of unique identifiers from aggregate root to the entity that emitted the event.
// */
// @NotNull
// public EntityIdPath getEntityIdPath();
//
// /**
// * Returns the identifier of the entity that caused this event. This is the last ID in the path.
// *
// * @return Entity identifier.
// */
// @NotNull
// public ID getEntityId();
//
// /**
// * Returns the version of the aggregate the entity belongs to.
// *
// * @return Aggregate version at the time the event was raised.
// */
// @Nullable
// public AggregateVersion getAggregateVersion();
//
// /**
// * Returns the aggregate version as integer. This is a null-safe shortcut for <code>getAggregateVersion().asBaseType()</code>-
// *
// * @return Expected version or {@literal null}.
// */
// @Nullable
// public Integer getAggregateVersionInteger();
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/Vendor.java
// public interface ConstructorService {
//
// /**
// * Adds a new vendor key to the context. The key will be persisted or an exception will be thrown if it already exists.
// *
// * @param key
// * Key to verify and persist.
// *
// * @throws DuplicateVendorKeyException
// * The given key already exists.
// */
// public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException;
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.UUID;
import org.fuin.ddd4j.ddd.DomainEvent;
import org.fuin.ddd4j.test.Vendor.ConstructorService;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class VendorExampleTest {
@Test
public void testConstructor() throws DuplicateVendorKeyException {
// PREPARE
VendorId id = new VendorId(UUID.randomUUID());
VendorKey key = new VendorKey("V00001");
VendorName name = new VendorName("Peter Parker Inc.");
ConstructorService service = new ConstructorService() {
@Override
public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException {
// Do nothing
}
};
// TEST
Vendor vendor = new Vendor(id, key, name, service);
// VERIFY
|
// Path: src/main/java/org/fuin/ddd4j/ddd/DomainEvent.java
// public interface DomainEvent<ID extends EntityId> extends Event {
//
// /**
// * Returns the path to the originator of the event.
// *
// * @return List of unique identifiers from aggregate root to the entity that emitted the event.
// */
// @NotNull
// public EntityIdPath getEntityIdPath();
//
// /**
// * Returns the identifier of the entity that caused this event. This is the last ID in the path.
// *
// * @return Entity identifier.
// */
// @NotNull
// public ID getEntityId();
//
// /**
// * Returns the version of the aggregate the entity belongs to.
// *
// * @return Aggregate version at the time the event was raised.
// */
// @Nullable
// public AggregateVersion getAggregateVersion();
//
// /**
// * Returns the aggregate version as integer. This is a null-safe shortcut for <code>getAggregateVersion().asBaseType()</code>-
// *
// * @return Expected version or {@literal null}.
// */
// @Nullable
// public Integer getAggregateVersionInteger();
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/Vendor.java
// public interface ConstructorService {
//
// /**
// * Adds a new vendor key to the context. The key will be persisted or an exception will be thrown if it already exists.
// *
// * @param key
// * Key to verify and persist.
// *
// * @throws DuplicateVendorKeyException
// * The given key already exists.
// */
// public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException;
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorExampleTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.UUID;
import org.fuin.ddd4j.ddd.DomainEvent;
import org.fuin.ddd4j.test.Vendor.ConstructorService;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class VendorExampleTest {
@Test
public void testConstructor() throws DuplicateVendorKeyException {
// PREPARE
VendorId id = new VendorId(UUID.randomUUID());
VendorKey key = new VendorKey("V00001");
VendorName name = new VendorName("Peter Parker Inc.");
ConstructorService service = new ConstructorService() {
@Override
public void addVendorKey(VendorKey key) throws DuplicateVendorKeyException {
// Do nothing
}
};
// TEST
Vendor vendor = new Vendor(id, key, name, service);
// VERIFY
|
List<DomainEvent<?>> events = vendor.getUncommittedChanges();
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/AggregateAlreadyExistsException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* An aggregate already exists when trying to create it.
*/
public final class AggregateAlreadyExistsException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateAlreadyExistsException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateAlreadyExistsException.java
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* An aggregate already exists when trying to create it.
*/
public final class AggregateAlreadyExistsException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateAlreadyExistsException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-AGGREGATE_ALREADY_EXISTS";
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/EncryptionKeyVersionUnknownException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the requested version of the encryption key is unknown.
*/
public final class EncryptionKeyVersionUnknownException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EncryptionKeyVersionUnknownException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/EncryptionKeyVersionUnknownException.java
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the requested version of the encryption key is unknown.
*/
public final class EncryptionKeyVersionUnknownException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EncryptionKeyVersionUnknownException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-ENCRYPTION_KEY_VERSION_UNKNOWN";
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/EntityNotFoundException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.Nullable;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an entity was not found.
*/
public final class EntityNotFoundException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EntityNotFoundException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityNotFoundException.java
import org.fuin.objects4j.common.Nullable;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that an entity was not found.
*/
public final class EntityNotFoundException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<EntityNotFoundException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-ENTITY_NOT_FOUND";
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AbstractDomainEventTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.UUID;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
|
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class AbstractDomainEventTest {
private static final EventType MY_EVENT_1_TYPE = new EventType("MyEvent1");
private static final EventType MY_EVENT_2_TYPE = new EventType("MyEvent2");
@Test
public final void testConstructorCorrelationCausationIds() {
// PREPARE
final EventId correlationId = new EventId();
final EventId causationId = new EventId();
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AbstractDomainEventTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.UUID;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class AbstractDomainEventTest {
private static final EventType MY_EVENT_1_TYPE = new EventType("MyEvent1");
private static final EventType MY_EVENT_2_TYPE = new EventType("MyEvent2");
@Test
public final void testConstructorCorrelationCausationIds() {
// PREPARE
final EventId correlationId = new EventId();
final EventId causationId = new EventId();
|
final VendorId vendorId = new VendorId();
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AbstractDomainEventTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.UUID;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
|
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class AbstractDomainEventTest {
private static final EventType MY_EVENT_1_TYPE = new EventType("MyEvent1");
private static final EventType MY_EVENT_2_TYPE = new EventType("MyEvent2");
@Test
public final void testConstructorCorrelationCausationIds() {
// PREPARE
final EventId correlationId = new EventId();
final EventId causationId = new EventId();
final VendorId vendorId = new VendorId();
// TEST
final AbstractDomainEvent<VendorId> testee = new MyEvent1(vendorId, correlationId, causationId);
// VERIFY
assertThat(testee.getEntityId()).isEqualTo(vendorId);
assertThat(testee.getEntityIdPath()).isEqualTo(new EntityIdPath(vendorId));
assertThat(testee.getEventId()).isNotNull();
assertThat(testee.getEventTimestamp()).isNotNull();
assertThat(testee.getCausationId()).isEqualTo(causationId);
assertThat(testee.getCorrelationId()).isEqualTo(correlationId);
assertThat(testee.getEventType()).isEqualTo(MY_EVENT_1_TYPE);
}
@Test
public final void testConstructorEvent() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AbstractDomainEventTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.UUID;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class AbstractDomainEventTest {
private static final EventType MY_EVENT_1_TYPE = new EventType("MyEvent1");
private static final EventType MY_EVENT_2_TYPE = new EventType("MyEvent2");
@Test
public final void testConstructorCorrelationCausationIds() {
// PREPARE
final EventId correlationId = new EventId();
final EventId causationId = new EventId();
final VendorId vendorId = new VendorId();
// TEST
final AbstractDomainEvent<VendorId> testee = new MyEvent1(vendorId, correlationId, causationId);
// VERIFY
assertThat(testee.getEntityId()).isEqualTo(vendorId);
assertThat(testee.getEntityIdPath()).isEqualTo(new EntityIdPath(vendorId));
assertThat(testee.getEventId()).isNotNull();
assertThat(testee.getEventTimestamp()).isNotNull();
assertThat(testee.getCausationId()).isEqualTo(causationId);
assertThat(testee.getCorrelationId()).isEqualTo(correlationId);
assertThat(testee.getEventType()).isEqualTo(MY_EVENT_1_TYPE);
}
@Test
public final void testConstructorEvent() {
// PREPARE
|
final AId aid = new AId(1L);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/BId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class BId implements EntityId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class BId implements EntityId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("B");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/BId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class BId implements EntityId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class BId implements EntityId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("B");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
|
public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
private static final long serialVersionUID = 1000L;
/** Type of entity this identifier represents. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
private static final long serialVersionUID = 1000L;
/** Type of entity this identifier represents. */
|
public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/VendorId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
private static final long serialVersionUID = 1000L;
/** Type of entity this identifier represents. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
import java.util.UUID;
import org.fuin.objects4j.common.Immutable;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.vo.AbstractUuidValueObject;
import org.fuin.objects4j.vo.ValueObjectWithBaseType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
/**
* Unique identifier of a customer.
*/
@Immutable
@XmlJavaTypeAdapter(VendorIdConverter.class)
public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
private static final long serialVersionUID = 1000L;
/** Type of entity this identifier represents. */
|
public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/CId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class CId implements EntityId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class CId implements EntityId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("C");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/test/CId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
|
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class CId implements EntityId {
private static final long serialVersionUID = 1L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityId.java
// public interface EntityId extends TechnicalId {
//
// /**
// * Returns the type represented by this identifier.
// *
// * @return Type of entity.
// */
// public EntityType getType();
//
// /**
// * Returns the entity identifier as string.
// *
// * @return Entity identifier.
// */
// public String asString();
//
// /**
// * Returns the entity identifier as string with type and identifier.
// *
// * @return Type and identifier.
// */
// public String asTypedString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/StringBasedEntityType.java
// @Immutable
// public final class StringBasedEntityType extends AbstractStringValueObject implements EntityType {
//
// private static final long serialVersionUID = 1000L;
//
// @NotEmpty
// @Size(max = 255)
// private final String str;
//
// /**
// * Constructor with unique name to use.
// *
// * @param str
// * Type name of an aggregate that is unique within all types of the context
// */
// public StringBasedEntityType(@NotEmpty @Size(max = 255) final String str) {
// Contract.requireArgNotEmpty("str", str);
// Contract.requireArgMaxLength("str", str, 255);
// this.str = str;
// }
//
// @Override
// public final String asBaseType() {
// return str;
// }
//
// @Override
// public final String toString() {
// return str;
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.test;
//CHECKSTYLE:OFF
public class CId implements EntityId {
private static final long serialVersionUID = 1L;
|
public static final EntityType TYPE = new StringBasedEntityType("C");
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AggregateDeletedExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateDeletedException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateDeletedExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AggregateDeletedExceptionTest.java
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateDeletedException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateDeletedExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final VendorId vendorId = new VendorId(UUID.fromString("4dcf4c2c-10e1-4db9-ba9e-d1e644e9d119"));
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/DuplicateEncryptionKeyIdException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the encryption key identifier already exists and cannot be created a second time.
*/
public final class DuplicateEncryptionKeyIdException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DuplicateEncryptionKeyIdException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/DuplicateEncryptionKeyIdException.java
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that the encryption key identifier already exists and cannot be created a second time.
*/
public final class DuplicateEncryptionKeyIdException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DuplicateEncryptionKeyIdException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-DUPLICATE-ENCRYPTION_KEY_ID";
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/DecryptionFailedException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that decrypting the data failed.
*/
public final class DecryptionFailedException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DecryptionFailedException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/DecryptionFailedException.java
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals that decrypting the data failed.
*/
public final class DecryptionFailedException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<DecryptionFailedException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-DECRYPTION_FAILED";
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AggregateAlreadyExistsExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateAlreadyExistsException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateAlreadyExistsExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AggregateAlreadyExistsExceptionTest.java
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateAlreadyExistsException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateAlreadyExistsExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final VendorId vendorId = new VendorId(UUID.fromString("4dcf4c2c-10e1-4db9-ba9e-d1e644e9d119"));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/AggregateNotFoundExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
|
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/VendorId.java
// @Immutable
// @XmlJavaTypeAdapter(VendorIdConverter.class)
// public final class VendorId extends AbstractUuidValueObject implements AggregateRootId, ValueObjectWithBaseType<UUID> {
//
// private static final long serialVersionUID = 1000L;
//
// /** Type of entity this identifier represents. */
// public static final EntityType ENTITY_TYPE = new StringBasedEntityType("Vendor");
//
// private final UUID uuid;
//
// /**
// * Default constructor.
// */
// public VendorId() {
// super();
// uuid = UUID.randomUUID();
// }
//
// /**
// * Constructor with UUID.
// *
// * @param uuid
// * UUID.
// */
// public VendorId(@NotNull final UUID uuid) {
// super();
// Contract.requireArgNotNull("uuid", uuid);
// this.uuid = uuid;
// }
//
// @Override
// public final UUID asBaseType() {
// return uuid;
// }
//
// @Override
// public final EntityType getType() {
// return ENTITY_TYPE;
// }
//
// @Override
// public final String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public final String asString() {
// return uuid.toString();
// }
//
// @Override
// public final String toString() {
// return uuid.toString();
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/AggregateNotFoundExceptionTest.java
import org.fuin.ddd4j.test.VendorId;
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.util.UUID;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link AggregateNotFoundException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class AggregateNotFoundExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final VendorId vendorId = new VendorId(UUID.fromString("4dcf4c2c-10e1-4db9-ba9e-d1e644e9d119"));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/DomainEventExpectedEntityIdPathValidatorTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/ACreatedEvent.java
// public class ACreatedEvent extends AbstractDomainEvent<AId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("ACreatedEvent");
//
// private AId id;
//
// public ACreatedEvent(final AId id) {
// super(new EntityIdPath(id));
// this.id = id;
// }
//
// public AId getId() {
// return id;
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CAddedEvent.java
// public class CAddedEvent extends AbstractDomainEvent<BId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("CAddedEvent");
//
// private final CId cid;
//
// public CAddedEvent(final AId aid, final BId bid, final CId cid) {
// super(new EntityIdPath(aid, bid));
// this.cid = cid;
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// public CId getCId() {
// return cid;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CEvent.java
// public class CEvent extends AbstractDomainEvent<CId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("CEvent");
//
// public CEvent(final AId aid, final BId bid, final CId cid) {
// super(new EntityIdPath(aid, bid, cid));
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.ACreatedEvent;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CAddedEvent;
import org.fuin.ddd4j.test.CEvent;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class DomainEventExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/ACreatedEvent.java
// public class ACreatedEvent extends AbstractDomainEvent<AId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("ACreatedEvent");
//
// private AId id;
//
// public ACreatedEvent(final AId id) {
// super(new EntityIdPath(id));
// this.id = id;
// }
//
// public AId getId() {
// return id;
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CAddedEvent.java
// public class CAddedEvent extends AbstractDomainEvent<BId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("CAddedEvent");
//
// private final CId cid;
//
// public CAddedEvent(final AId aid, final BId bid, final CId cid) {
// super(new EntityIdPath(aid, bid));
// this.cid = cid;
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// public CId getCId() {
// return cid;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CEvent.java
// public class CEvent extends AbstractDomainEvent<CId> {
//
// private static final long serialVersionUID = 1L;
//
// private static final EventType EVENT_TYPE = new EventType("CEvent");
//
// public CEvent(final AId aid, final BId bid, final CId cid) {
// super(new EntityIdPath(aid, bid, cid));
// }
//
// @Override
// public EventType getEventType() {
// return EVENT_TYPE;
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/DomainEventExpectedEntityIdPathValidatorTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.ACreatedEvent;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CAddedEvent;
import org.fuin.ddd4j.test.CEvent;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class DomainEventExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
|
final DomainEventExpectedEntityIdPath anno = createAnnotation(AId.class);
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/esrepo/AggregateStreamId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
|
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.fuin.objects4j.common.Immutable;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.esc.api.StreamId;
import org.fuin.objects4j.vo.KeyValue;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.esrepo;
/**
* Unique name of an aggregate stream. Equals and has code are based on the {@link #asString()} method.
*/
@Immutable
public final class AggregateStreamId implements StreamId {
private static final long serialVersionUID = 1000L;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
// Path: src/main/java/org/fuin/ddd4j/esrepo/AggregateStreamId.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.fuin.objects4j.common.Immutable;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.esc.api.StreamId;
import org.fuin.objects4j.vo.KeyValue;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.esrepo;
/**
* Unique name of an aggregate stream. Equals and has code are based on the {@link #asString()} method.
*/
@Immutable
public final class AggregateStreamId implements StreamId {
private static final long serialVersionUID = 1000L;
|
private EntityType type;
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/esrepo/AggregateStreamId.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
|
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.fuin.objects4j.common.Immutable;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.esc.api.StreamId;
import org.fuin.objects4j.vo.KeyValue;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.esrepo;
/**
* Unique name of an aggregate stream. Equals and has code are based on the {@link #asString()} method.
*/
@Immutable
public final class AggregateStreamId implements StreamId {
private static final long serialVersionUID = 1000L;
private EntityType type;
private String paramName;
|
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateRootId.java
// public interface AggregateRootId extends EntityId {
//
// }
//
// Path: src/main/java/org/fuin/ddd4j/ddd/EntityType.java
// public interface EntityType extends Serializable {
//
// /**
// * Returns the entity type name as string.
// *
// * @return Unique entity type name.
// */
// public String asString();
//
// }
// Path: src/main/java/org/fuin/ddd4j/esrepo/AggregateStreamId.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.fuin.objects4j.common.Immutable;
import org.fuin.ddd4j.ddd.AggregateRootId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.esc.api.StreamId;
import org.fuin.objects4j.vo.KeyValue;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.esrepo;
/**
* Unique name of an aggregate stream. Equals and has code are based on the {@link #asString()} method.
*/
@Immutable
public final class AggregateStreamId implements StreamId {
private static final long serialVersionUID = 1000L;
private EntityType type;
private String paramName;
|
private AggregateRootId paramValue;
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/DuplicateEntityExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
|
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link DuplicateEntityException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class DuplicateEntityExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/DuplicateEntityExceptionTest.java
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link DuplicateEntityException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class DuplicateEntityExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final DuplicateEntityException original = new DuplicateEntityException(new EntityIdPath(new AId(1L)), new BId(1));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/DuplicateEntityExceptionTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
|
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link DuplicateEntityException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class DuplicateEntityExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/DuplicateEntityExceptionTest.java
import org.junit.Test;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.JaxbUtils.marshal;
import static org.fuin.utils4j.JaxbUtils.unmarshal;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
import jakarta.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Tests for {@link DuplicateEntityException}.
*/
// CHECKSTYLE:OFF Disabled for test
public class DuplicateEntityExceptionTest {
@Test
public void testSerializeDeserialize() {
// PREPARE
|
final DuplicateEntityException original = new DuplicateEntityException(new EntityIdPath(new AId(1L)), new BId(1));
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
|
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: 'X 1'");
}
try {
testee.requireArgValid("a", "");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: ''");
}
}
@Test
public void testToVOSingle() {
// PREPARE
final EntityIdPathConverter testee = new EntityIdPathConverter(new MyIdFactory());
EntityIdPath path;
Iterator<EntityId> it;
EntityId first;
EntityId last;
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: 'X 1'");
}
try {
testee.requireArgValid("a", "");
fail("Expected exception");
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'a' is not valid: ''");
}
}
@Test
public void testToVOSingle() {
// PREPARE
final EntityIdPathConverter testee = new EntityIdPathConverter(new MyIdFactory());
EntityIdPath path;
Iterator<EntityId> it;
EntityId first;
EntityId last;
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
|
assertValues(first, AId.class, "A", 1L);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
|
}
@Test
public void testToVOSingle() {
// PREPARE
final EntityIdPathConverter testee = new EntityIdPathConverter(new MyIdFactory());
EntityIdPath path;
Iterator<EntityId> it;
EntityId first;
EntityId last;
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, AId.class, "A", 1L);
assertThat(first).isSameAs(last);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertThat(it.hasNext()).isFalse();
// Two
path = testee.toVO("A 1/B 2");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
}
@Test
public void testToVOSingle() {
// PREPARE
final EntityIdPathConverter testee = new EntityIdPathConverter(new MyIdFactory());
EntityIdPath path;
Iterator<EntityId> it;
EntityId first;
EntityId last;
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, AId.class, "A", 1L);
assertThat(first).isSameAs(last);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertThat(it.hasNext()).isFalse();
// Two
path = testee.toVO("A 1/B 2");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
|
assertValues(last, BId.class, "B", 2L);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
|
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, AId.class, "A", 1L);
assertThat(first).isSameAs(last);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertThat(it.hasNext()).isFalse();
// Two
path = testee.toVO("A 1/B 2");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, BId.class, "B", 2L);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertValues(it.next(), BId.class, "B", 2L);
assertThat(it.hasNext()).isFalse();
// Three
path = testee.toVO("A 1/B 2/C 3");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/EntityIdPathConverterTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.Iterator;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
// TEST & VERIFY
// Single
path = testee.toVO("A 1");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, AId.class, "A", 1L);
assertThat(first).isSameAs(last);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertThat(it.hasNext()).isFalse();
// Two
path = testee.toVO("A 1/B 2");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
assertValues(last, BId.class, "B", 2L);
it = path.iterator();
assertValues(it.next(), AId.class, "A", 1L);
assertValues(it.next(), BId.class, "B", 2L);
assertThat(it.hasNext()).isFalse();
// Three
path = testee.toVO("A 1/B 2/C 3");
first = path.first();
last = path.last();
assertValues(first, AId.class, "A", 1L);
|
assertValues(last, CId.class, "C", 3L);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
|
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(null, null)).isTrue();
}
@Test
public void testIsValidOneLevel() {
// PREPARE
final AId aid = new AId(1L);
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(null, null)).isTrue();
}
@Test
public void testIsValidOneLevel() {
// PREPARE
final AId aid = new AId(1L);
|
final BId bid = new BId(2L);
|
fuinorg/ddd-4-java
|
src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
|
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(null, null)).isTrue();
}
@Test
public void testIsValidOneLevel() {
// PREPARE
final AId aid = new AId(1L);
final BId bid = new BId(2L);
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(new EntityIdPath(aid), null)).isTrue();
assertThat(testee.isValid(new EntityIdPath(bid), null)).isFalse();
assertThat(testee.isValid(new EntityIdPath(aid, bid), null)).isFalse();
}
@Test
public void testIsValidTwoLevel() {
// PREPARE
final AId aid = new AId(1L);
final BId bid = new BId(2L);
|
// Path: src/test/java/org/fuin/ddd4j/test/AId.java
// public class AId implements ImplRootId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("A");
//
// private final long id;
//
// public AId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "AId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/BId.java
// public class BId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("B");
//
// private final long id;
//
// public BId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "BId [id=" + id + "]";
// }
//
// }
//
// Path: src/test/java/org/fuin/ddd4j/test/CId.java
// public class CId implements EntityId {
//
// private static final long serialVersionUID = 1L;
//
// public static final EntityType TYPE = new StringBasedEntityType("C");
//
// private final long id;
//
// public CId(final long id) {
// this.id = id;
// }
//
// @Override
// public EntityType getType() {
// return TYPE;
// }
//
// @Override
// public String asString() {
// return "" + id;
// }
//
// @Override
// public String asTypedString() {
// return getType() + " " + asString();
// }
//
// @Override
// public String toString() {
// return "CId [id=" + id + "]";
// }
//
// }
// Path: src/test/java/org/fuin/ddd4j/ddd/ExpectedEntityIdPathValidatorTest.java
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.annotation.Annotation;
import jakarta.validation.Payload;
import org.fuin.ddd4j.test.AId;
import org.fuin.ddd4j.test.BId;
import org.fuin.ddd4j.test.CId;
import org.junit.Test;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
//CHECKSTYLE:OFF Test code
public class ExpectedEntityIdPathValidatorTest {
@Test
public void testIsValidNull() {
// PREPARE
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(null, null)).isTrue();
}
@Test
public void testIsValidOneLevel() {
// PREPARE
final AId aid = new AId(1L);
final BId bid = new BId(2L);
final ExpectedEntityIdPath anno = createAnnotation(AId.class);
final ExpectedEntityIdPathValidator testee = new ExpectedEntityIdPathValidator();
testee.initialize(anno);
// TEST & VERIFY
assertThat(testee.isValid(new EntityIdPath(aid), null)).isTrue();
assertThat(testee.isValid(new EntityIdPath(bid), null)).isFalse();
assertThat(testee.isValid(new EntityIdPath(aid, bid), null)).isFalse();
}
@Test
public void testIsValidTwoLevel() {
// PREPARE
final AId aid = new AId(1L);
final BId bid = new BId(2L);
|
final CId cid = new CId(3L);
|
fuinorg/ddd-4-java
|
src/main/java/org/fuin/ddd4j/ddd/AggregateVersionConflictException.java
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
|
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
|
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals a conflict between an expected and an actual version for an aggregate.
*/
public final class AggregateVersionConflictException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateVersionConflictException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
// Path: src/main/java/org/fuin/ddd4j/ddd/Ddd4JUtils.java
// public static final String SHORT_ID_PREFIX = "DDD4J";
// Path: src/main/java/org/fuin/ddd4j/ddd/AggregateVersionConflictException.java
import org.fuin.objects4j.common.MarshalInformation;
import org.fuin.objects4j.common.ToExceptionCapable;
import org.fuin.objects4j.vo.ValueObject;
import static org.fuin.ddd4j.ddd.Ddd4JUtils.SHORT_ID_PREFIX;
import java.io.Serializable;
import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.validation.constraints.NotNull;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import org.fuin.objects4j.common.Contract;
import org.fuin.objects4j.common.ExceptionShortIdentifable;
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.ddd4j.ddd;
/**
* Signals a conflict between an expected and an actual version for an aggregate.
*/
public final class AggregateVersionConflictException extends Exception
implements ExceptionShortIdentifable, MarshalInformation<AggregateVersionConflictException.Data> {
private static final long serialVersionUID = 1L;
/** Unique short identifier of this exception. */
|
public static final String SHORT_ID = SHORT_ID_PREFIX + "-AGGREGATE_VERSION_CONFLICT";
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.