From c9f2b8592b2e9ba9cdba11691c7e878df2d53e6a Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 10:20:59 +0100 Subject: [PATCH 1/9] Made Kernel.java as interface, extracted class into BaseKernel.java --- .../de/dmi3y/behaiv/kernel/BaseKernel.java | 100 ++++++++++++++++++ .../java/de/dmi3y/behaiv/kernel/Kernel.java | 88 +++------------ .../kernel/LogisticRegressionKernel.java | 2 +- src/test/java/de/dmi3y/behaiv/BehaivTest.java | 5 +- 4 files changed, 119 insertions(+), 76 deletions(-) create mode 100644 src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java diff --git a/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java b/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java new file mode 100644 index 0000000..04ef86b --- /dev/null +++ b/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java @@ -0,0 +1,100 @@ +package de.dmi3y.behaiv.kernel; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import de.dmi3y.behaiv.storage.BehaivStorage; +import de.dmi3y.behaiv.tools.Pair; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public abstract class BaseKernel implements Kernel { + + protected String id; + protected Long treshold = 10L; + protected ObjectMapper objectMapper; + protected boolean partialFitAllowed = false; + protected boolean alwaysKeepData = true; + + public BaseKernel(String id) { + this.id = id; + objectMapper = new ObjectMapper(); + } + + + @Override + public void setId(String id) { + this.id = id; + } + + + //list, label + protected List, String>> data = new ArrayList<>(); + + + @Override + public void fit() { + fit(this.data); + } + + @Override + public void setTreshold(Long treshold) { + this.treshold = treshold; + } + + @Override + public boolean readyToPredict() { + return data.size() > treshold; + } + + @Override + public void update(List, String>> data) { + } + + @Override + public boolean isPartialFitAllowed() { + return partialFitAllowed; + } + + @Override + public void updateSingle(List features, String label) { + data.add(new Pair<>(features, label)); + } + + @Override + public boolean isAlwaysKeepData() { + return alwaysKeepData; + } + + @Override + public void setAlwaysKeepData(boolean alwaysKeepData) { + this.alwaysKeepData = alwaysKeepData; + } + + @Override + public void save(BehaivStorage storage) throws IOException { + + try (final BufferedWriter writer = new BufferedWriter(new FileWriter(storage.getDataFile(id)))) { + writer.write(objectMapper.writeValueAsString(data)); + } + } + + @Override + public void restore(BehaivStorage storage) throws IOException { + final TypeReference, String>>> typeReference = new TypeReference, String>>>() { + }; + try (final BufferedReader reader = new BufferedReader(new FileReader(storage.getDataFile(id)))) { + final String content = reader.readLine(); + if (content == null || content.isEmpty()) { + data = new ArrayList<>(); + } else { + data = objectMapper.readValue(content, typeReference); + } + } + } +} diff --git a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java index ec414f5..b2db896 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java @@ -1,95 +1,37 @@ package de.dmi3y.behaiv.kernel; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import de.dmi3y.behaiv.storage.BehaivStorage; import de.dmi3y.behaiv.tools.Pair; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; -import java.util.ArrayList; import java.util.List; -public abstract class Kernel { +public interface Kernel { + void setId(String id); - protected String id; - protected Long treshold = 10L; - protected ObjectMapper objectMapper; - protected boolean partialFitAllowed = false; - protected boolean alwaysKeepData = true; + boolean isEmpty(); - public Kernel(String id) { - this.id = id; - objectMapper = new ObjectMapper(); - } + void fit(List, String>> data); + void fit(); - public void setId(String id) { - this.id = id; - } + void setTreshold(Long treshold); + boolean readyToPredict(); - //list, label - protected List, String>> data = new ArrayList<>(); + void update(List, String>> data); + boolean isPartialFitAllowed(); - public abstract boolean isEmpty(); + void updateSingle(List features, String label); - public abstract void fit(List, String>> data); + String predictOne(List features); - public void fit() { - fit(this.data); - } + boolean isAlwaysKeepData(); - public void setTreshold(Long treshold) { - this.treshold = treshold; - } + void setAlwaysKeepData(boolean alwaysKeepData); - public boolean readyToPredict() { - return data.size() > treshold; - } + void save(BehaivStorage storage) throws IOException; - public void update(List, String>> data) { - } - - public boolean isPartialFitAllowed() { - return partialFitAllowed; - } - - public void updateSingle(List features, String label) { - data.add(new Pair<>(features, label)); - } - - public abstract String predictOne(List features); - - public boolean isAlwaysKeepData() { - return alwaysKeepData; - } - - public void setAlwaysKeepData(boolean alwaysKeepData) { - this.alwaysKeepData = alwaysKeepData; - } - - public void save(BehaivStorage storage) throws IOException { - - try (final BufferedWriter writer = new BufferedWriter(new FileWriter(storage.getDataFile(id)))) { - writer.write(objectMapper.writeValueAsString(data)); - } - } - - public void restore(BehaivStorage storage) throws IOException { - final TypeReference, String>>> typeReference = new TypeReference, String>>>() { - }; - try (final BufferedReader reader = new BufferedReader(new FileReader(storage.getDataFile(id)))) { - final String content = reader.readLine(); - if (content == null || content.isEmpty()) { - data = new ArrayList<>(); - } else { - data = objectMapper.readValue(content, typeReference); - } - } - } + void restore(BehaivStorage storage) throws IOException; } diff --git a/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java b/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java index 5205d25..3337192 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java @@ -17,7 +17,7 @@ import static de.dmi3y.behaiv.tools.DataMappingUtils.toDistinctListOfPairValues; import static de.dmi3y.behaiv.tools.DataMappingUtils.toInput2dArray; -public class LogisticRegressionKernel extends Kernel { +public class LogisticRegressionKernel extends BaseKernel { protected List labels = new ArrayList<>(); private Random rand; diff --git a/src/test/java/de/dmi3y/behaiv/BehaivTest.java b/src/test/java/de/dmi3y/behaiv/BehaivTest.java index 9c9091b..354eea4 100644 --- a/src/test/java/de/dmi3y/behaiv/BehaivTest.java +++ b/src/test/java/de/dmi3y/behaiv/BehaivTest.java @@ -1,5 +1,6 @@ package de.dmi3y.behaiv; +import de.dmi3y.behaiv.kernel.BaseKernel; import de.dmi3y.behaiv.kernel.Kernel; import de.dmi3y.behaiv.kernel.LogisticRegressionKernel; import de.dmi3y.behaiv.provider.DayTimeProvider; @@ -59,7 +60,7 @@ public void stopCapturing_whenDiscard_sessionShouldBeNull() { @Test public void startCapturing_tryToRestore_restoreNetwork() throws IOException { - final Kernel mockKernel = mock(Kernel.class); + final Kernel mockKernel = mock(BaseKernel.class); final BehaivStorage storage = mock(BehaivStorage.class); final Behaiv behaiv = new Behaiv.Builder("testId") .setKernel(mockKernel) @@ -75,7 +76,7 @@ public void startCapturing_tryToRestore_restoreNetwork() throws IOException { @Test public void startCapturing_withIOException_continueWithoutSaving() throws IOException { - final Kernel testKernel = mock(Kernel.class); + final Kernel testKernel = mock(BaseKernel.class); final BehaivStorage storage = mock(BehaivStorage.class); final Behaiv behaiv = Behaiv.with("testId") .setKernel(testKernel) From 5c4cf4d1045d50063736aa9b88d9c87c0f9ce8a3 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 10:45:39 +0100 Subject: [PATCH 2/9] Added generated proto files --- .../java/tech/donau/behaiv/proto/Action.java | 1379 +++++++++++++++++ .../donau/behaiv/proto/ActionOrBuilder.java | 114 ++ .../java/tech/donau/behaiv/proto/Behaiv.java | 112 ++ .../java/tech/donau/behaiv/proto/Data.java | 627 ++++++++ .../donau/behaiv/proto/DataOrBuilder.java | 27 + .../tech/donau/behaiv/proto/Prediction.java | 901 +++++++++++ .../behaiv/proto/PredictionOrBuilder.java | 45 + .../donau/behaiv/proto/PredictionSet.java | 765 +++++++++ .../behaiv/proto/PredictionSetOrBuilder.java | 33 + .../java/tech/donau/behaiv/proto/Screen.java | 617 ++++++++ .../donau/behaiv/proto/ScreenOrBuilder.java | 27 + 11 files changed, 4647 insertions(+) create mode 100644 src/main/java/tech/donau/behaiv/proto/Action.java create mode 100644 src/main/java/tech/donau/behaiv/proto/ActionOrBuilder.java create mode 100644 src/main/java/tech/donau/behaiv/proto/Behaiv.java create mode 100644 src/main/java/tech/donau/behaiv/proto/Data.java create mode 100644 src/main/java/tech/donau/behaiv/proto/DataOrBuilder.java create mode 100644 src/main/java/tech/donau/behaiv/proto/Prediction.java create mode 100644 src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java create mode 100644 src/main/java/tech/donau/behaiv/proto/PredictionSet.java create mode 100644 src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java create mode 100644 src/main/java/tech/donau/behaiv/proto/Screen.java create mode 100644 src/main/java/tech/donau/behaiv/proto/ScreenOrBuilder.java diff --git a/src/main/java/tech/donau/behaiv/proto/Action.java b/src/main/java/tech/donau/behaiv/proto/Action.java new file mode 100644 index 0000000..942d4f8 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/Action.java @@ -0,0 +1,1379 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +/** + *
+ * Communication messages
+ * 
+ * + * Protobuf type {@code Action} + */ +public final class Action extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Action) + ActionOrBuilder { +private static final long serialVersionUID = 0L; + // Use Action.newBuilder() to construct. + private Action(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Action() { + action_ = ""; + object_ = ""; + screenStack_ = emptyIntList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Action(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Action( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + localId_ = input.readInt64(); + break; + } + case 16: { + + prevLocalId_ = input.readInt64(); + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + action_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + object_ = s; + break; + } + case 40: { + + currentScreenId_ = input.readInt32(); + break; + } + case 48: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + screenStack_ = newIntList(); + mutable_bitField0_ |= 0x00000001; + } + screenStack_.addInt(input.readInt32()); + break; + } + case 50: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000001) != 0) && input.getBytesUntilLimit() > 0) { + screenStack_ = newIntList(); + mutable_bitField0_ |= 0x00000001; + } + while (input.getBytesUntilLimit() > 0) { + screenStack_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000002; + } + com.google.protobuf.MapEntry + attributes__ = input.readMessage( + AttributesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + attributes_.getMutableMap().put( + attributes__.getKey(), attributes__.getValue()); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + screenStack_.makeImmutable(); // C + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Action_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Action.class, tech.donau.behaiv.proto.Action.Builder.class); + } + + public static final int LOCAL_ID_FIELD_NUMBER = 1; + private long localId_; + /** + * int64 local_id = 1; + * @return The localId. + */ + public long getLocalId() { + return localId_; + } + + public static final int PREV_LOCAL_ID_FIELD_NUMBER = 2; + private long prevLocalId_; + /** + * int64 prev_local_id = 2; + * @return The prevLocalId. + */ + public long getPrevLocalId() { + return prevLocalId_; + } + + public static final int ACTION_FIELD_NUMBER = 3; + private volatile java.lang.Object action_; + /** + * string action = 3; + * @return The action. + */ + public java.lang.String getAction() { + java.lang.Object ref = action_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + action_ = s; + return s; + } + } + /** + * string action = 3; + * @return The bytes for action. + */ + public com.google.protobuf.ByteString + getActionBytes() { + java.lang.Object ref = action_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + action_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OBJECT_FIELD_NUMBER = 4; + private volatile java.lang.Object object_; + /** + * string object = 4; + * @return The object. + */ + public java.lang.String getObject() { + java.lang.Object ref = object_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + object_ = s; + return s; + } + } + /** + * string object = 4; + * @return The bytes for object. + */ + public com.google.protobuf.ByteString + getObjectBytes() { + java.lang.Object ref = object_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + object_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CURRENT_SCREEN_ID_FIELD_NUMBER = 5; + private int currentScreenId_; + /** + * int32 current_screen_id = 5; + * @return The currentScreenId. + */ + public int getCurrentScreenId() { + return currentScreenId_; + } + + public static final int SCREEN_STACK_FIELD_NUMBER = 6; + private com.google.protobuf.Internal.IntList screenStack_; + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @return A list containing the screenStack. + */ + public java.util.List + getScreenStackList() { + return screenStack_; + } + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @return The count of screenStack. + */ + public int getScreenStackCount() { + return screenStack_.size(); + } + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @param index The index of the element to return. + * @return The screenStack at the given index. + */ + public int getScreenStack(int index) { + return screenStack_.getInt(index); + } + private int screenStackMemoizedSerializedSize = -1; + + public static final int ATTRIBUTES_FIELD_NUMBER = 8; + private static final class AttributesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + tech.donau.behaiv.proto.Behaiv.internal_static_Action_AttributesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + + public int getAttributesCount() { + return internalGetAttributes().getMap().size(); + } + /** + * map<string, string> attributes = 8; + */ + + public boolean containsAttributes( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAttributes().getMap().containsKey(key); + } + /** + * Use {@link #getAttributesMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAttributes() { + return getAttributesMap(); + } + /** + * map<string, string> attributes = 8; + */ + + public java.util.Map getAttributesMap() { + return internalGetAttributes().getMap(); + } + /** + * map<string, string> attributes = 8; + */ + + public java.lang.String getAttributesOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> attributes = 8; + */ + + public java.lang.String getAttributesOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (localId_ != 0L) { + output.writeInt64(1, localId_); + } + if (prevLocalId_ != 0L) { + output.writeInt64(2, prevLocalId_); + } + if (!getActionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, action_); + } + if (!getObjectBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, object_); + } + if (currentScreenId_ != 0) { + output.writeInt32(5, currentScreenId_); + } + if (getScreenStackList().size() > 0) { + output.writeUInt32NoTag(50); + output.writeUInt32NoTag(screenStackMemoizedSerializedSize); + } + for (int i = 0; i < screenStack_.size(); i++) { + output.writeInt32NoTag(screenStack_.getInt(i)); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetAttributes(), + AttributesDefaultEntryHolder.defaultEntry, + 8); + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (localId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(1, localId_); + } + if (prevLocalId_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, prevLocalId_); + } + if (!getActionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, action_); + } + if (!getObjectBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, object_); + } + if (currentScreenId_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, currentScreenId_); + } + { + int dataSize = 0; + for (int i = 0; i < screenStack_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(screenStack_.getInt(i)); + } + size += dataSize; + if (!getScreenStackList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + screenStackMemoizedSerializedSize = dataSize; + } + for (java.util.Map.Entry entry + : internalGetAttributes().getMap().entrySet()) { + com.google.protobuf.MapEntry + attributes__ = AttributesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, attributes__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof tech.donau.behaiv.proto.Action)) { + return super.equals(obj); + } + tech.donau.behaiv.proto.Action other = (tech.donau.behaiv.proto.Action) obj; + + if (getLocalId() + != other.getLocalId()) return false; + if (getPrevLocalId() + != other.getPrevLocalId()) return false; + if (!getAction() + .equals(other.getAction())) return false; + if (!getObject() + .equals(other.getObject())) return false; + if (getCurrentScreenId() + != other.getCurrentScreenId()) return false; + if (!getScreenStackList() + .equals(other.getScreenStackList())) return false; + if (!internalGetAttributes().equals( + other.internalGetAttributes())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + LOCAL_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getLocalId()); + hash = (37 * hash) + PREV_LOCAL_ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getPrevLocalId()); + hash = (37 * hash) + ACTION_FIELD_NUMBER; + hash = (53 * hash) + getAction().hashCode(); + hash = (37 * hash) + OBJECT_FIELD_NUMBER; + hash = (53 * hash) + getObject().hashCode(); + hash = (37 * hash) + CURRENT_SCREEN_ID_FIELD_NUMBER; + hash = (53 * hash) + getCurrentScreenId(); + if (getScreenStackCount() > 0) { + hash = (37 * hash) + SCREEN_STACK_FIELD_NUMBER; + hash = (53 * hash) + getScreenStackList().hashCode(); + } + if (!internalGetAttributes().getMap().isEmpty()) { + hash = (37 * hash) + ATTRIBUTES_FIELD_NUMBER; + hash = (53 * hash) + internalGetAttributes().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static tech.donau.behaiv.proto.Action parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Action parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Action parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Action parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Action parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Action parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Action parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Action parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Action parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Action parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Action parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Action parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(tech.donau.behaiv.proto.Action prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * Communication messages
+   * 
+ * + * Protobuf type {@code Action} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Action) + tech.donau.behaiv.proto.ActionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Action_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 8: + return internalGetMutableAttributes(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Action.class, tech.donau.behaiv.proto.Action.Builder.class); + } + + // Construct using tech.donau.behaiv.proto.Action.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + localId_ = 0L; + + prevLocalId_ = 0L; + + action_ = ""; + + object_ = ""; + + currentScreenId_ = 0; + + screenStack_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000001); + internalGetMutableAttributes().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Action_descriptor; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Action getDefaultInstanceForType() { + return tech.donau.behaiv.proto.Action.getDefaultInstance(); + } + + @java.lang.Override + public tech.donau.behaiv.proto.Action build() { + tech.donau.behaiv.proto.Action result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Action buildPartial() { + tech.donau.behaiv.proto.Action result = new tech.donau.behaiv.proto.Action(this); + int from_bitField0_ = bitField0_; + result.localId_ = localId_; + result.prevLocalId_ = prevLocalId_; + result.action_ = action_; + result.object_ = object_; + result.currentScreenId_ = currentScreenId_; + if (((bitField0_ & 0x00000001) != 0)) { + screenStack_.makeImmutable(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.screenStack_ = screenStack_; + result.attributes_ = internalGetAttributes(); + result.attributes_.makeImmutable(); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof tech.donau.behaiv.proto.Action) { + return mergeFrom((tech.donau.behaiv.proto.Action)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(tech.donau.behaiv.proto.Action other) { + if (other == tech.donau.behaiv.proto.Action.getDefaultInstance()) return this; + if (other.getLocalId() != 0L) { + setLocalId(other.getLocalId()); + } + if (other.getPrevLocalId() != 0L) { + setPrevLocalId(other.getPrevLocalId()); + } + if (!other.getAction().isEmpty()) { + action_ = other.action_; + onChanged(); + } + if (!other.getObject().isEmpty()) { + object_ = other.object_; + onChanged(); + } + if (other.getCurrentScreenId() != 0) { + setCurrentScreenId(other.getCurrentScreenId()); + } + if (!other.screenStack_.isEmpty()) { + if (screenStack_.isEmpty()) { + screenStack_ = other.screenStack_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureScreenStackIsMutable(); + screenStack_.addAll(other.screenStack_); + } + onChanged(); + } + internalGetMutableAttributes().mergeFrom( + other.internalGetAttributes()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + tech.donau.behaiv.proto.Action parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (tech.donau.behaiv.proto.Action) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private long localId_ ; + /** + * int64 local_id = 1; + * @return The localId. + */ + public long getLocalId() { + return localId_; + } + /** + * int64 local_id = 1; + * @param value The localId to set. + * @return This builder for chaining. + */ + public Builder setLocalId(long value) { + + localId_ = value; + onChanged(); + return this; + } + /** + * int64 local_id = 1; + * @return This builder for chaining. + */ + public Builder clearLocalId() { + + localId_ = 0L; + onChanged(); + return this; + } + + private long prevLocalId_ ; + /** + * int64 prev_local_id = 2; + * @return The prevLocalId. + */ + public long getPrevLocalId() { + return prevLocalId_; + } + /** + * int64 prev_local_id = 2; + * @param value The prevLocalId to set. + * @return This builder for chaining. + */ + public Builder setPrevLocalId(long value) { + + prevLocalId_ = value; + onChanged(); + return this; + } + /** + * int64 prev_local_id = 2; + * @return This builder for chaining. + */ + public Builder clearPrevLocalId() { + + prevLocalId_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object action_ = ""; + /** + * string action = 3; + * @return The action. + */ + public java.lang.String getAction() { + java.lang.Object ref = action_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + action_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string action = 3; + * @return The bytes for action. + */ + public com.google.protobuf.ByteString + getActionBytes() { + java.lang.Object ref = action_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + action_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string action = 3; + * @param value The action to set. + * @return This builder for chaining. + */ + public Builder setAction( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + action_ = value; + onChanged(); + return this; + } + /** + * string action = 3; + * @return This builder for chaining. + */ + public Builder clearAction() { + + action_ = getDefaultInstance().getAction(); + onChanged(); + return this; + } + /** + * string action = 3; + * @param value The bytes for action to set. + * @return This builder for chaining. + */ + public Builder setActionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + action_ = value; + onChanged(); + return this; + } + + private java.lang.Object object_ = ""; + /** + * string object = 4; + * @return The object. + */ + public java.lang.String getObject() { + java.lang.Object ref = object_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + object_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string object = 4; + * @return The bytes for object. + */ + public com.google.protobuf.ByteString + getObjectBytes() { + java.lang.Object ref = object_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + object_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string object = 4; + * @param value The object to set. + * @return This builder for chaining. + */ + public Builder setObject( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + object_ = value; + onChanged(); + return this; + } + /** + * string object = 4; + * @return This builder for chaining. + */ + public Builder clearObject() { + + object_ = getDefaultInstance().getObject(); + onChanged(); + return this; + } + /** + * string object = 4; + * @param value The bytes for object to set. + * @return This builder for chaining. + */ + public Builder setObjectBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + object_ = value; + onChanged(); + return this; + } + + private int currentScreenId_ ; + /** + * int32 current_screen_id = 5; + * @return The currentScreenId. + */ + public int getCurrentScreenId() { + return currentScreenId_; + } + /** + * int32 current_screen_id = 5; + * @param value The currentScreenId to set. + * @return This builder for chaining. + */ + public Builder setCurrentScreenId(int value) { + + currentScreenId_ = value; + onChanged(); + return this; + } + /** + * int32 current_screen_id = 5; + * @return This builder for chaining. + */ + public Builder clearCurrentScreenId() { + + currentScreenId_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Internal.IntList screenStack_ = emptyIntList(); + private void ensureScreenStackIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + screenStack_ = mutableCopy(screenStack_); + bitField0_ |= 0x00000001; + } + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @return A list containing the screenStack. + */ + public java.util.List + getScreenStackList() { + return ((bitField0_ & 0x00000001) != 0) ? + java.util.Collections.unmodifiableList(screenStack_) : screenStack_; + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @return The count of screenStack. + */ + public int getScreenStackCount() { + return screenStack_.size(); + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @param index The index of the element to return. + * @return The screenStack at the given index. + */ + public int getScreenStack(int index) { + return screenStack_.getInt(index); + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @param index The index to set the value at. + * @param value The screenStack to set. + * @return This builder for chaining. + */ + public Builder setScreenStack( + int index, int value) { + ensureScreenStackIsMutable(); + screenStack_.setInt(index, value); + onChanged(); + return this; + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @param value The screenStack to add. + * @return This builder for chaining. + */ + public Builder addScreenStack(int value) { + ensureScreenStackIsMutable(); + screenStack_.addInt(value); + onChanged(); + return this; + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @param values The screenStack to add. + * @return This builder for chaining. + */ + public Builder addAllScreenStack( + java.lang.Iterable values) { + ensureScreenStackIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, screenStack_); + onChanged(); + return this; + } + /** + *
+     *    repeated Event events = 7; TODO
+     * 
+ * + * repeated int32 screen_stack = 6; + * @return This builder for chaining. + */ + public Builder clearScreenStack() { + screenStack_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> attributes_; + private com.google.protobuf.MapField + internalGetAttributes() { + if (attributes_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + return attributes_; + } + private com.google.protobuf.MapField + internalGetMutableAttributes() { + onChanged();; + if (attributes_ == null) { + attributes_ = com.google.protobuf.MapField.newMapField( + AttributesDefaultEntryHolder.defaultEntry); + } + if (!attributes_.isMutable()) { + attributes_ = attributes_.copy(); + } + return attributes_; + } + + public int getAttributesCount() { + return internalGetAttributes().getMap().size(); + } + /** + * map<string, string> attributes = 8; + */ + + public boolean containsAttributes( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + return internalGetAttributes().getMap().containsKey(key); + } + /** + * Use {@link #getAttributesMap()} instead. + */ + @java.lang.Deprecated + public java.util.Map getAttributes() { + return getAttributesMap(); + } + /** + * map<string, string> attributes = 8; + */ + + public java.util.Map getAttributesMap() { + return internalGetAttributes().getMap(); + } + /** + * map<string, string> attributes = 8; + */ + + public java.lang.String getAttributesOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> attributes = 8; + */ + + public java.lang.String getAttributesOrThrow( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + java.util.Map map = + internalGetAttributes().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearAttributes() { + internalGetMutableAttributes().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> attributes = 8; + */ + + public Builder removeAttributes( + java.lang.String key) { + if (key == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAttributes().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableAttributes() { + return internalGetMutableAttributes().getMutableMap(); + } + /** + * map<string, string> attributes = 8; + */ + public Builder putAttributes( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new java.lang.NullPointerException(); } + if (value == null) { throw new java.lang.NullPointerException(); } + internalGetMutableAttributes().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> attributes = 8; + */ + + public Builder putAllAttributes( + java.util.Map values) { + internalGetMutableAttributes().getMutableMap() + .putAll(values); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Action) + } + + // @@protoc_insertion_point(class_scope:Action) + private static final tech.donau.behaiv.proto.Action DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new tech.donau.behaiv.proto.Action(); + } + + public static tech.donau.behaiv.proto.Action getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Action parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Action(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Action getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/src/main/java/tech/donau/behaiv/proto/ActionOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/ActionOrBuilder.java new file mode 100644 index 0000000..dfc71cf --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/ActionOrBuilder.java @@ -0,0 +1,114 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public interface ActionOrBuilder extends + // @@protoc_insertion_point(interface_extends:Action) + com.google.protobuf.MessageOrBuilder { + + /** + * int64 local_id = 1; + * @return The localId. + */ + long getLocalId(); + + /** + * int64 prev_local_id = 2; + * @return The prevLocalId. + */ + long getPrevLocalId(); + + /** + * string action = 3; + * @return The action. + */ + java.lang.String getAction(); + /** + * string action = 3; + * @return The bytes for action. + */ + com.google.protobuf.ByteString + getActionBytes(); + + /** + * string object = 4; + * @return The object. + */ + java.lang.String getObject(); + /** + * string object = 4; + * @return The bytes for object. + */ + com.google.protobuf.ByteString + getObjectBytes(); + + /** + * int32 current_screen_id = 5; + * @return The currentScreenId. + */ + int getCurrentScreenId(); + + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @return A list containing the screenStack. + */ + java.util.List getScreenStackList(); + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @return The count of screenStack. + */ + int getScreenStackCount(); + /** + *
+   *    repeated Event events = 7; TODO
+   * 
+ * + * repeated int32 screen_stack = 6; + * @param index The index of the element to return. + * @return The screenStack at the given index. + */ + int getScreenStack(int index); + + /** + * map<string, string> attributes = 8; + */ + int getAttributesCount(); + /** + * map<string, string> attributes = 8; + */ + boolean containsAttributes( + java.lang.String key); + /** + * Use {@link #getAttributesMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getAttributes(); + /** + * map<string, string> attributes = 8; + */ + java.util.Map + getAttributesMap(); + /** + * map<string, string> attributes = 8; + */ + + java.lang.String getAttributesOrDefault( + java.lang.String key, + java.lang.String defaultValue); + /** + * map<string, string> attributes = 8; + */ + + java.lang.String getAttributesOrThrow( + java.lang.String key); +} diff --git a/src/main/java/tech/donau/behaiv/proto/Behaiv.java b/src/main/java/tech/donau/behaiv/proto/Behaiv.java new file mode 100644 index 0000000..7c5bde9 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/Behaiv.java @@ -0,0 +1,112 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public final class Behaiv { + private Behaiv() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_Data_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Data_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_Prediction_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Prediction_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_PredictionSet_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_PredictionSet_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_Action_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Action_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_Action_AttributesEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Action_AttributesEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_Screen_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Screen_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014behaiv.proto\"(\n\004Data\022\013\n\003key\030\002 \001(\t\022\r\n\005v" + + "alue\030\003 \001(\001J\004\010\001\020\002\"5\n\nPrediction\022\023\n\004data\030\001" + + " \003(\0132\005.Data\022\022\n\nprediction\030\002 \001(\t\"0\n\rPredi" + + "ctionSet\022\037\n\nprediction\030\001 \003(\0132\013.Predictio" + + "n\"\342\001\n\006Action\022\020\n\010local_id\030\001 \001(\003\022\025\n\rprev_l" + + "ocal_id\030\002 \001(\003\022\016\n\006action\030\003 \001(\t\022\016\n\006object\030" + + "\004 \001(\t\022\031\n\021current_screen_id\030\005 \001(\005\022\024\n\014scre" + + "en_stack\030\006 \003(\005\022+\n\nattributes\030\010 \003(\0132\027.Act" + + "ion.AttributesEntry\0321\n\017AttributesEntry\022\013" + + "\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\"\n\006Screen" + + "\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030\002 \001(\tB\033\n\027tech.donau" + + ".behaiv.protoP\001b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_Data_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Data_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Data_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_Prediction_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_Prediction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Prediction_descriptor, + new java.lang.String[] { "Data", "Prediction", }); + internal_static_PredictionSet_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_PredictionSet_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_PredictionSet_descriptor, + new java.lang.String[] { "Prediction", }); + internal_static_Action_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_Action_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Action_descriptor, + new java.lang.String[] { "LocalId", "PrevLocalId", "Action", "Object", "CurrentScreenId", "ScreenStack", "Attributes", }); + internal_static_Action_AttributesEntry_descriptor = + internal_static_Action_descriptor.getNestedTypes().get(0); + internal_static_Action_AttributesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Action_AttributesEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_Screen_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_Screen_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Screen_descriptor, + new java.lang.String[] { "Id", "Name", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/main/java/tech/donau/behaiv/proto/Data.java b/src/main/java/tech/donau/behaiv/proto/Data.java new file mode 100644 index 0000000..39ddec0 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/Data.java @@ -0,0 +1,627 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +/** + *
+ * Data messages
+ * 
+ * + * Protobuf type {@code Data} + */ +public final class Data extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Data) + DataOrBuilder { +private static final long serialVersionUID = 0L; + // Use Data.newBuilder() to construct. + private Data(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Data() { + key_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Data(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Data( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + key_ = s; + break; + } + case 25: { + + value_ = input.readDouble(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Data_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Data_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Data.class, tech.donau.behaiv.proto.Data.Builder.class); + } + + public static final int KEY_FIELD_NUMBER = 2; + private volatile java.lang.Object key_; + /** + * string key = 2; + * @return The key. + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } + } + /** + * string key = 2; + * @return The bytes for key. + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 3; + private double value_; + /** + * double value = 3; + * @return The value. + */ + public double getValue() { + return value_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getKeyBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, key_); + } + if (value_ != 0D) { + output.writeDouble(3, value_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getKeyBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, key_); + } + if (value_ != 0D) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(3, value_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof tech.donau.behaiv.proto.Data)) { + return super.equals(obj); + } + tech.donau.behaiv.proto.Data other = (tech.donau.behaiv.proto.Data) obj; + + if (!getKey() + .equals(other.getKey())) return false; + if (java.lang.Double.doubleToLongBits(getValue()) + != java.lang.Double.doubleToLongBits( + other.getValue())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getValue())); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static tech.donau.behaiv.proto.Data parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Data parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Data parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Data parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Data parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Data parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Data parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Data parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Data parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Data parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Data parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Data parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(tech.donau.behaiv.proto.Data prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * Data messages
+   * 
+ * + * Protobuf type {@code Data} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Data) + tech.donau.behaiv.proto.DataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Data_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Data_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Data.class, tech.donau.behaiv.proto.Data.Builder.class); + } + + // Construct using tech.donau.behaiv.proto.Data.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + key_ = ""; + + value_ = 0D; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Data_descriptor; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Data getDefaultInstanceForType() { + return tech.donau.behaiv.proto.Data.getDefaultInstance(); + } + + @java.lang.Override + public tech.donau.behaiv.proto.Data build() { + tech.donau.behaiv.proto.Data result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Data buildPartial() { + tech.donau.behaiv.proto.Data result = new tech.donau.behaiv.proto.Data(this); + result.key_ = key_; + result.value_ = value_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof tech.donau.behaiv.proto.Data) { + return mergeFrom((tech.donau.behaiv.proto.Data)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(tech.donau.behaiv.proto.Data other) { + if (other == tech.donau.behaiv.proto.Data.getDefaultInstance()) return this; + if (!other.getKey().isEmpty()) { + key_ = other.key_; + onChanged(); + } + if (other.getValue() != 0D) { + setValue(other.getValue()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + tech.donau.behaiv.proto.Data parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (tech.donau.behaiv.proto.Data) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object key_ = ""; + /** + * string key = 2; + * @return The key. + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + key_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string key = 2; + * @return The bytes for key. + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string key = 2; + * @param value The key to set. + * @return This builder for chaining. + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + key_ = value; + onChanged(); + return this; + } + /** + * string key = 2; + * @return This builder for chaining. + */ + public Builder clearKey() { + + key_ = getDefaultInstance().getKey(); + onChanged(); + return this; + } + /** + * string key = 2; + * @param value The bytes for key to set. + * @return This builder for chaining. + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + key_ = value; + onChanged(); + return this; + } + + private double value_ ; + /** + * double value = 3; + * @return The value. + */ + public double getValue() { + return value_; + } + /** + * double value = 3; + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue(double value) { + + value_ = value; + onChanged(); + return this; + } + /** + * double value = 3; + * @return This builder for chaining. + */ + public Builder clearValue() { + + value_ = 0D; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Data) + } + + // @@protoc_insertion_point(class_scope:Data) + private static final tech.donau.behaiv.proto.Data DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new tech.donau.behaiv.proto.Data(); + } + + public static tech.donau.behaiv.proto.Data getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Data parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Data(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Data getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/src/main/java/tech/donau/behaiv/proto/DataOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/DataOrBuilder.java new file mode 100644 index 0000000..f82daf4 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/DataOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public interface DataOrBuilder extends + // @@protoc_insertion_point(interface_extends:Data) + com.google.protobuf.MessageOrBuilder { + + /** + * string key = 2; + * @return The key. + */ + java.lang.String getKey(); + /** + * string key = 2; + * @return The bytes for key. + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * double value = 3; + * @return The value. + */ + double getValue(); +} diff --git a/src/main/java/tech/donau/behaiv/proto/Prediction.java b/src/main/java/tech/donau/behaiv/proto/Prediction.java new file mode 100644 index 0000000..a257ce7 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/Prediction.java @@ -0,0 +1,901 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +/** + * Protobuf type {@code Prediction} + */ +public final class Prediction extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Prediction) + PredictionOrBuilder { +private static final long serialVersionUID = 0L; + // Use Prediction.newBuilder() to construct. + private Prediction(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Prediction() { + data_ = java.util.Collections.emptyList(); + prediction_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Prediction(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Prediction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + data_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + data_.add( + input.readMessage(tech.donau.behaiv.proto.Data.parser(), extensionRegistry)); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + prediction_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + data_ = java.util.Collections.unmodifiableList(data_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Prediction_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Prediction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Prediction.class, tech.donau.behaiv.proto.Prediction.Builder.class); + } + + public static final int DATA_FIELD_NUMBER = 1; + private java.util.List data_; + /** + * repeated .Data data = 1; + */ + public java.util.List getDataList() { + return data_; + } + /** + * repeated .Data data = 1; + */ + public java.util.List + getDataOrBuilderList() { + return data_; + } + /** + * repeated .Data data = 1; + */ + public int getDataCount() { + return data_.size(); + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.Data getData(int index) { + return data_.get(index); + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.DataOrBuilder getDataOrBuilder( + int index) { + return data_.get(index); + } + + public static final int PREDICTION_FIELD_NUMBER = 2; + private volatile java.lang.Object prediction_; + /** + * string prediction = 2; + * @return The prediction. + */ + public java.lang.String getPrediction() { + java.lang.Object ref = prediction_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + prediction_ = s; + return s; + } + } + /** + * string prediction = 2; + * @return The bytes for prediction. + */ + public com.google.protobuf.ByteString + getPredictionBytes() { + java.lang.Object ref = prediction_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + prediction_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < data_.size(); i++) { + output.writeMessage(1, data_.get(i)); + } + if (!getPredictionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, prediction_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < data_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, data_.get(i)); + } + if (!getPredictionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, prediction_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof tech.donau.behaiv.proto.Prediction)) { + return super.equals(obj); + } + tech.donau.behaiv.proto.Prediction other = (tech.donau.behaiv.proto.Prediction) obj; + + if (!getDataList() + .equals(other.getDataList())) return false; + if (!getPrediction() + .equals(other.getPrediction())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDataCount() > 0) { + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getDataList().hashCode(); + } + hash = (37 * hash) + PREDICTION_FIELD_NUMBER; + hash = (53 * hash) + getPrediction().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static tech.donau.behaiv.proto.Prediction parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Prediction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Prediction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Prediction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Prediction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Prediction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(tech.donau.behaiv.proto.Prediction prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Prediction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Prediction) + tech.donau.behaiv.proto.PredictionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Prediction_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Prediction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Prediction.class, tech.donau.behaiv.proto.Prediction.Builder.class); + } + + // Construct using tech.donau.behaiv.proto.Prediction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getDataFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (dataBuilder_ == null) { + data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + dataBuilder_.clear(); + } + prediction_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Prediction_descriptor; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Prediction getDefaultInstanceForType() { + return tech.donau.behaiv.proto.Prediction.getDefaultInstance(); + } + + @java.lang.Override + public tech.donau.behaiv.proto.Prediction build() { + tech.donau.behaiv.proto.Prediction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Prediction buildPartial() { + tech.donau.behaiv.proto.Prediction result = new tech.donau.behaiv.proto.Prediction(this); + int from_bitField0_ = bitField0_; + if (dataBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + data_ = java.util.Collections.unmodifiableList(data_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.data_ = data_; + } else { + result.data_ = dataBuilder_.build(); + } + result.prediction_ = prediction_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof tech.donau.behaiv.proto.Prediction) { + return mergeFrom((tech.donau.behaiv.proto.Prediction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(tech.donau.behaiv.proto.Prediction other) { + if (other == tech.donau.behaiv.proto.Prediction.getDefaultInstance()) return this; + if (dataBuilder_ == null) { + if (!other.data_.isEmpty()) { + if (data_.isEmpty()) { + data_ = other.data_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDataIsMutable(); + data_.addAll(other.data_); + } + onChanged(); + } + } else { + if (!other.data_.isEmpty()) { + if (dataBuilder_.isEmpty()) { + dataBuilder_.dispose(); + dataBuilder_ = null; + data_ = other.data_; + bitField0_ = (bitField0_ & ~0x00000001); + dataBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getDataFieldBuilder() : null; + } else { + dataBuilder_.addAllMessages(other.data_); + } + } + } + if (!other.getPrediction().isEmpty()) { + prediction_ = other.prediction_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + tech.donau.behaiv.proto.Prediction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (tech.donau.behaiv.proto.Prediction) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List data_ = + java.util.Collections.emptyList(); + private void ensureDataIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + data_ = new java.util.ArrayList(data_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Data, tech.donau.behaiv.proto.Data.Builder, tech.donau.behaiv.proto.DataOrBuilder> dataBuilder_; + + /** + * repeated .Data data = 1; + */ + public java.util.List getDataList() { + if (dataBuilder_ == null) { + return java.util.Collections.unmodifiableList(data_); + } else { + return dataBuilder_.getMessageList(); + } + } + /** + * repeated .Data data = 1; + */ + public int getDataCount() { + if (dataBuilder_ == null) { + return data_.size(); + } else { + return dataBuilder_.getCount(); + } + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.Data getData(int index) { + if (dataBuilder_ == null) { + return data_.get(index); + } else { + return dataBuilder_.getMessage(index); + } + } + /** + * repeated .Data data = 1; + */ + public Builder setData( + int index, tech.donau.behaiv.proto.Data value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDataIsMutable(); + data_.set(index, value); + onChanged(); + } else { + dataBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder setData( + int index, tech.donau.behaiv.proto.Data.Builder builderForValue) { + if (dataBuilder_ == null) { + ensureDataIsMutable(); + data_.set(index, builderForValue.build()); + onChanged(); + } else { + dataBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder addData(tech.donau.behaiv.proto.Data value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDataIsMutable(); + data_.add(value); + onChanged(); + } else { + dataBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder addData( + int index, tech.donau.behaiv.proto.Data value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDataIsMutable(); + data_.add(index, value); + onChanged(); + } else { + dataBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder addData( + tech.donau.behaiv.proto.Data.Builder builderForValue) { + if (dataBuilder_ == null) { + ensureDataIsMutable(); + data_.add(builderForValue.build()); + onChanged(); + } else { + dataBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder addData( + int index, tech.donau.behaiv.proto.Data.Builder builderForValue) { + if (dataBuilder_ == null) { + ensureDataIsMutable(); + data_.add(index, builderForValue.build()); + onChanged(); + } else { + dataBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder addAllData( + java.lang.Iterable values) { + if (dataBuilder_ == null) { + ensureDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, data_); + onChanged(); + } else { + dataBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder clearData() { + if (dataBuilder_ == null) { + data_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + dataBuilder_.clear(); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public Builder removeData(int index) { + if (dataBuilder_ == null) { + ensureDataIsMutable(); + data_.remove(index); + onChanged(); + } else { + dataBuilder_.remove(index); + } + return this; + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.Data.Builder getDataBuilder( + int index) { + return getDataFieldBuilder().getBuilder(index); + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.DataOrBuilder getDataOrBuilder( + int index) { + if (dataBuilder_ == null) { + return data_.get(index); } else { + return dataBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .Data data = 1; + */ + public java.util.List + getDataOrBuilderList() { + if (dataBuilder_ != null) { + return dataBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(data_); + } + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.Data.Builder addDataBuilder() { + return getDataFieldBuilder().addBuilder( + tech.donau.behaiv.proto.Data.getDefaultInstance()); + } + /** + * repeated .Data data = 1; + */ + public tech.donau.behaiv.proto.Data.Builder addDataBuilder( + int index) { + return getDataFieldBuilder().addBuilder( + index, tech.donau.behaiv.proto.Data.getDefaultInstance()); + } + /** + * repeated .Data data = 1; + */ + public java.util.List + getDataBuilderList() { + return getDataFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Data, tech.donau.behaiv.proto.Data.Builder, tech.donau.behaiv.proto.DataOrBuilder> + getDataFieldBuilder() { + if (dataBuilder_ == null) { + dataBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Data, tech.donau.behaiv.proto.Data.Builder, tech.donau.behaiv.proto.DataOrBuilder>( + data_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + data_ = null; + } + return dataBuilder_; + } + + private java.lang.Object prediction_ = ""; + /** + * string prediction = 2; + * @return The prediction. + */ + public java.lang.String getPrediction() { + java.lang.Object ref = prediction_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + prediction_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string prediction = 2; + * @return The bytes for prediction. + */ + public com.google.protobuf.ByteString + getPredictionBytes() { + java.lang.Object ref = prediction_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + prediction_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string prediction = 2; + * @param value The prediction to set. + * @return This builder for chaining. + */ + public Builder setPrediction( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + prediction_ = value; + onChanged(); + return this; + } + /** + * string prediction = 2; + * @return This builder for chaining. + */ + public Builder clearPrediction() { + + prediction_ = getDefaultInstance().getPrediction(); + onChanged(); + return this; + } + /** + * string prediction = 2; + * @param value The bytes for prediction to set. + * @return This builder for chaining. + */ + public Builder setPredictionBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + prediction_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Prediction) + } + + // @@protoc_insertion_point(class_scope:Prediction) + private static final tech.donau.behaiv.proto.Prediction DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new tech.donau.behaiv.proto.Prediction(); + } + + public static tech.donau.behaiv.proto.Prediction getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Prediction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Prediction(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Prediction getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java new file mode 100644 index 0000000..db9546a --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public interface PredictionOrBuilder extends + // @@protoc_insertion_point(interface_extends:Prediction) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .Data data = 1; + */ + java.util.List + getDataList(); + /** + * repeated .Data data = 1; + */ + tech.donau.behaiv.proto.Data getData(int index); + /** + * repeated .Data data = 1; + */ + int getDataCount(); + /** + * repeated .Data data = 1; + */ + java.util.List + getDataOrBuilderList(); + /** + * repeated .Data data = 1; + */ + tech.donau.behaiv.proto.DataOrBuilder getDataOrBuilder( + int index); + + /** + * string prediction = 2; + * @return The prediction. + */ + java.lang.String getPrediction(); + /** + * string prediction = 2; + * @return The bytes for prediction. + */ + com.google.protobuf.ByteString + getPredictionBytes(); +} diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionSet.java b/src/main/java/tech/donau/behaiv/proto/PredictionSet.java new file mode 100644 index 0000000..bc2fb05 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/PredictionSet.java @@ -0,0 +1,765 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +/** + * Protobuf type {@code PredictionSet} + */ +public final class PredictionSet extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:PredictionSet) + PredictionSetOrBuilder { +private static final long serialVersionUID = 0L; + // Use PredictionSet.newBuilder() to construct. + private PredictionSet(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PredictionSet() { + prediction_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PredictionSet(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PredictionSet( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + prediction_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + prediction_.add( + input.readMessage(tech.donau.behaiv.proto.Prediction.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + prediction_ = java.util.Collections.unmodifiableList(prediction_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_PredictionSet_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_PredictionSet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.PredictionSet.class, tech.donau.behaiv.proto.PredictionSet.Builder.class); + } + + public static final int PREDICTION_FIELD_NUMBER = 1; + private java.util.List prediction_; + /** + * repeated .Prediction prediction = 1; + */ + public java.util.List getPredictionList() { + return prediction_; + } + /** + * repeated .Prediction prediction = 1; + */ + public java.util.List + getPredictionOrBuilderList() { + return prediction_; + } + /** + * repeated .Prediction prediction = 1; + */ + public int getPredictionCount() { + return prediction_.size(); + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.Prediction getPrediction(int index) { + return prediction_.get(index); + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.PredictionOrBuilder getPredictionOrBuilder( + int index) { + return prediction_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < prediction_.size(); i++) { + output.writeMessage(1, prediction_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < prediction_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, prediction_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof tech.donau.behaiv.proto.PredictionSet)) { + return super.equals(obj); + } + tech.donau.behaiv.proto.PredictionSet other = (tech.donau.behaiv.proto.PredictionSet) obj; + + if (!getPredictionList() + .equals(other.getPredictionList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getPredictionCount() > 0) { + hash = (37 * hash) + PREDICTION_FIELD_NUMBER; + hash = (53 * hash) + getPredictionList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.PredictionSet parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.PredictionSet parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.PredictionSet parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(tech.donau.behaiv.proto.PredictionSet prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code PredictionSet} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:PredictionSet) + tech.donau.behaiv.proto.PredictionSetOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_PredictionSet_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_PredictionSet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.PredictionSet.class, tech.donau.behaiv.proto.PredictionSet.Builder.class); + } + + // Construct using tech.donau.behaiv.proto.PredictionSet.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getPredictionFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + if (predictionBuilder_ == null) { + prediction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + predictionBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return tech.donau.behaiv.proto.Behaiv.internal_static_PredictionSet_descriptor; + } + + @java.lang.Override + public tech.donau.behaiv.proto.PredictionSet getDefaultInstanceForType() { + return tech.donau.behaiv.proto.PredictionSet.getDefaultInstance(); + } + + @java.lang.Override + public tech.donau.behaiv.proto.PredictionSet build() { + tech.donau.behaiv.proto.PredictionSet result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public tech.donau.behaiv.proto.PredictionSet buildPartial() { + tech.donau.behaiv.proto.PredictionSet result = new tech.donau.behaiv.proto.PredictionSet(this); + int from_bitField0_ = bitField0_; + if (predictionBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + prediction_ = java.util.Collections.unmodifiableList(prediction_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.prediction_ = prediction_; + } else { + result.prediction_ = predictionBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof tech.donau.behaiv.proto.PredictionSet) { + return mergeFrom((tech.donau.behaiv.proto.PredictionSet)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(tech.donau.behaiv.proto.PredictionSet other) { + if (other == tech.donau.behaiv.proto.PredictionSet.getDefaultInstance()) return this; + if (predictionBuilder_ == null) { + if (!other.prediction_.isEmpty()) { + if (prediction_.isEmpty()) { + prediction_ = other.prediction_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePredictionIsMutable(); + prediction_.addAll(other.prediction_); + } + onChanged(); + } + } else { + if (!other.prediction_.isEmpty()) { + if (predictionBuilder_.isEmpty()) { + predictionBuilder_.dispose(); + predictionBuilder_ = null; + prediction_ = other.prediction_; + bitField0_ = (bitField0_ & ~0x00000001); + predictionBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getPredictionFieldBuilder() : null; + } else { + predictionBuilder_.addAllMessages(other.prediction_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + tech.donau.behaiv.proto.PredictionSet parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (tech.donau.behaiv.proto.PredictionSet) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List prediction_ = + java.util.Collections.emptyList(); + private void ensurePredictionIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + prediction_ = new java.util.ArrayList(prediction_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Prediction, tech.donau.behaiv.proto.Prediction.Builder, tech.donau.behaiv.proto.PredictionOrBuilder> predictionBuilder_; + + /** + * repeated .Prediction prediction = 1; + */ + public java.util.List getPredictionList() { + if (predictionBuilder_ == null) { + return java.util.Collections.unmodifiableList(prediction_); + } else { + return predictionBuilder_.getMessageList(); + } + } + /** + * repeated .Prediction prediction = 1; + */ + public int getPredictionCount() { + if (predictionBuilder_ == null) { + return prediction_.size(); + } else { + return predictionBuilder_.getCount(); + } + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.Prediction getPrediction(int index) { + if (predictionBuilder_ == null) { + return prediction_.get(index); + } else { + return predictionBuilder_.getMessage(index); + } + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder setPrediction( + int index, tech.donau.behaiv.proto.Prediction value) { + if (predictionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePredictionIsMutable(); + prediction_.set(index, value); + onChanged(); + } else { + predictionBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder setPrediction( + int index, tech.donau.behaiv.proto.Prediction.Builder builderForValue) { + if (predictionBuilder_ == null) { + ensurePredictionIsMutable(); + prediction_.set(index, builderForValue.build()); + onChanged(); + } else { + predictionBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder addPrediction(tech.donau.behaiv.proto.Prediction value) { + if (predictionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePredictionIsMutable(); + prediction_.add(value); + onChanged(); + } else { + predictionBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder addPrediction( + int index, tech.donau.behaiv.proto.Prediction value) { + if (predictionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePredictionIsMutable(); + prediction_.add(index, value); + onChanged(); + } else { + predictionBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder addPrediction( + tech.donau.behaiv.proto.Prediction.Builder builderForValue) { + if (predictionBuilder_ == null) { + ensurePredictionIsMutable(); + prediction_.add(builderForValue.build()); + onChanged(); + } else { + predictionBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder addPrediction( + int index, tech.donau.behaiv.proto.Prediction.Builder builderForValue) { + if (predictionBuilder_ == null) { + ensurePredictionIsMutable(); + prediction_.add(index, builderForValue.build()); + onChanged(); + } else { + predictionBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder addAllPrediction( + java.lang.Iterable values) { + if (predictionBuilder_ == null) { + ensurePredictionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, prediction_); + onChanged(); + } else { + predictionBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder clearPrediction() { + if (predictionBuilder_ == null) { + prediction_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + predictionBuilder_.clear(); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public Builder removePrediction(int index) { + if (predictionBuilder_ == null) { + ensurePredictionIsMutable(); + prediction_.remove(index); + onChanged(); + } else { + predictionBuilder_.remove(index); + } + return this; + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.Prediction.Builder getPredictionBuilder( + int index) { + return getPredictionFieldBuilder().getBuilder(index); + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.PredictionOrBuilder getPredictionOrBuilder( + int index) { + if (predictionBuilder_ == null) { + return prediction_.get(index); } else { + return predictionBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .Prediction prediction = 1; + */ + public java.util.List + getPredictionOrBuilderList() { + if (predictionBuilder_ != null) { + return predictionBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(prediction_); + } + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.Prediction.Builder addPredictionBuilder() { + return getPredictionFieldBuilder().addBuilder( + tech.donau.behaiv.proto.Prediction.getDefaultInstance()); + } + /** + * repeated .Prediction prediction = 1; + */ + public tech.donau.behaiv.proto.Prediction.Builder addPredictionBuilder( + int index) { + return getPredictionFieldBuilder().addBuilder( + index, tech.donau.behaiv.proto.Prediction.getDefaultInstance()); + } + /** + * repeated .Prediction prediction = 1; + */ + public java.util.List + getPredictionBuilderList() { + return getPredictionFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Prediction, tech.donau.behaiv.proto.Prediction.Builder, tech.donau.behaiv.proto.PredictionOrBuilder> + getPredictionFieldBuilder() { + if (predictionBuilder_ == null) { + predictionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + tech.donau.behaiv.proto.Prediction, tech.donau.behaiv.proto.Prediction.Builder, tech.donau.behaiv.proto.PredictionOrBuilder>( + prediction_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + prediction_ = null; + } + return predictionBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:PredictionSet) + } + + // @@protoc_insertion_point(class_scope:PredictionSet) + private static final tech.donau.behaiv.proto.PredictionSet DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new tech.donau.behaiv.proto.PredictionSet(); + } + + public static tech.donau.behaiv.proto.PredictionSet getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PredictionSet parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PredictionSet(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public tech.donau.behaiv.proto.PredictionSet getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java new file mode 100644 index 0000000..8252e1d --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public interface PredictionSetOrBuilder extends + // @@protoc_insertion_point(interface_extends:PredictionSet) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .Prediction prediction = 1; + */ + java.util.List + getPredictionList(); + /** + * repeated .Prediction prediction = 1; + */ + tech.donau.behaiv.proto.Prediction getPrediction(int index); + /** + * repeated .Prediction prediction = 1; + */ + int getPredictionCount(); + /** + * repeated .Prediction prediction = 1; + */ + java.util.List + getPredictionOrBuilderList(); + /** + * repeated .Prediction prediction = 1; + */ + tech.donau.behaiv.proto.PredictionOrBuilder getPredictionOrBuilder( + int index); +} diff --git a/src/main/java/tech/donau/behaiv/proto/Screen.java b/src/main/java/tech/donau/behaiv/proto/Screen.java new file mode 100644 index 0000000..0c80fe3 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/Screen.java @@ -0,0 +1,617 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +/** + * Protobuf type {@code Screen} + */ +public final class Screen extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:Screen) + ScreenOrBuilder { +private static final long serialVersionUID = 0L; + // Use Screen.newBuilder() to construct. + private Screen(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Screen() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Screen(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Screen( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + id_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Screen_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Screen_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Screen.class, tech.donau.behaiv.proto.Screen.Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + private int id_; + /** + * int32 id = 1; + * @return The id. + */ + public int getId() { + return id_; + } + + public static final int NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object name_; + /** + * string name = 2; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * string name = 2; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (id_ != 0) { + output.writeInt32(1, id_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (id_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, id_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, name_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof tech.donau.behaiv.proto.Screen)) { + return super.equals(obj); + } + tech.donau.behaiv.proto.Screen other = (tech.donau.behaiv.proto.Screen) obj; + + if (getId() + != other.getId()) return false; + if (!getName() + .equals(other.getName())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static tech.donau.behaiv.proto.Screen parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Screen parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static tech.donau.behaiv.proto.Screen parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Screen parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Screen parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static tech.donau.behaiv.proto.Screen parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(tech.donau.behaiv.proto.Screen prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code Screen} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:Screen) + tech.donau.behaiv.proto.ScreenOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Screen_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Screen_fieldAccessorTable + .ensureFieldAccessorsInitialized( + tech.donau.behaiv.proto.Screen.class, tech.donau.behaiv.proto.Screen.Builder.class); + } + + // Construct using tech.donau.behaiv.proto.Screen.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + id_ = 0; + + name_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return tech.donau.behaiv.proto.Behaiv.internal_static_Screen_descriptor; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Screen getDefaultInstanceForType() { + return tech.donau.behaiv.proto.Screen.getDefaultInstance(); + } + + @java.lang.Override + public tech.donau.behaiv.proto.Screen build() { + tech.donau.behaiv.proto.Screen result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Screen buildPartial() { + tech.donau.behaiv.proto.Screen result = new tech.donau.behaiv.proto.Screen(this); + result.id_ = id_; + result.name_ = name_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof tech.donau.behaiv.proto.Screen) { + return mergeFrom((tech.donau.behaiv.proto.Screen)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(tech.donau.behaiv.proto.Screen other) { + if (other == tech.donau.behaiv.proto.Screen.getDefaultInstance()) return this; + if (other.getId() != 0) { + setId(other.getId()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + tech.donau.behaiv.proto.Screen parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (tech.donau.behaiv.proto.Screen) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int id_ ; + /** + * int32 id = 1; + * @return The id. + */ + public int getId() { + return id_; + } + /** + * int32 id = 1; + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(int value) { + + id_ = value; + onChanged(); + return this; + } + /** + * int32 id = 1; + * @return This builder for chaining. + */ + public Builder clearId() { + + id_ = 0; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * string name = 2; + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string name = 2; + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string name = 2; + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * string name = 2; + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * string name = 2; + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:Screen) + } + + // @@protoc_insertion_point(class_scope:Screen) + private static final tech.donau.behaiv.proto.Screen DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new tech.donau.behaiv.proto.Screen(); + } + + public static tech.donau.behaiv.proto.Screen getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Screen parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Screen(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public tech.donau.behaiv.proto.Screen getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/src/main/java/tech/donau/behaiv/proto/ScreenOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/ScreenOrBuilder.java new file mode 100644 index 0000000..e258da2 --- /dev/null +++ b/src/main/java/tech/donau/behaiv/proto/ScreenOrBuilder.java @@ -0,0 +1,27 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: behaiv.proto + +package tech.donau.behaiv.proto; + +public interface ScreenOrBuilder extends + // @@protoc_insertion_point(interface_extends:Screen) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 id = 1; + * @return The id. + */ + int getId(); + + /** + * string name = 2; + * @return The name. + */ + java.lang.String getName(); + /** + * string name = 2; + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); +} From 9eb81f55ad8b1ea619e6662214e4f8b0a4f19d00 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 10:46:32 +0100 Subject: [PATCH 3/9] Added method to convert List,String> to PredictionSet --- .../dmi3y/behaiv/tools/DataMappingUtils.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java b/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java index a66f278..718b98a 100644 --- a/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java +++ b/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java @@ -1,6 +1,9 @@ package de.dmi3y.behaiv.tools; import org.apache.commons.lang3.ArrayUtils; +import tech.donau.behaiv.proto.Data; +import tech.donau.behaiv.proto.Prediction; +import tech.donau.behaiv.proto.PredictionSet; import java.util.ArrayList; import java.util.HashSet; @@ -14,6 +17,23 @@ private DataMappingUtils() { // Unused utility class } + public static PredictionSet createPredictionSet(List, String>> data) { + final PredictionSet.Builder predictionSetBuilder = PredictionSet.newBuilder(); + for (int i = 0; i < data.size(); i++) { + final List weights = data.get(i).getKey(); + final ArrayList row = new ArrayList<>(); + for (int j = 0; j < weights.size(); j++) { + row.add(Data.newBuilder().setKey("key"+j).setValue(weights.get(j)).build()); + } + predictionSetBuilder.addPrediction( + Prediction.newBuilder() + .addAllData(row) + .setPrediction(data.get(i).getValue()) + .build() + ); + } + return predictionSetBuilder.build(); + } public static List toDistinctListOfPairValues(List, String>> data) { Set setOfValues = new HashSet<>(); From fb4bcb2948cce7f6fdd3fa3a3d5749b9f1a76e39 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 12:30:56 +0100 Subject: [PATCH 4/9] Test for DataMappingUtilsTest::createPredictionSet --- .../dmi3y/behaiv/tools/DataMappingUtilsTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java b/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java index 09e218e..f9f5f50 100644 --- a/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java +++ b/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java @@ -2,6 +2,8 @@ import org.junit.Test; import org.mockito.internal.matchers.Null; +import tech.donau.behaiv.proto.Prediction; +import tech.donau.behaiv.proto.PredictionSet; import java.util.ArrayList; import java.util.Arrays; @@ -13,6 +15,19 @@ public class DataMappingUtilsTest { + + @Test + public void createPredictionSet_feedDefaultTestData_expectCorrectOrder() { + final Pair, String> mockData = getMockPairListDoubleStringData(); + final PredictionSet predictionSet = DataMappingUtils.createPredictionSet(Collections.singletonList(mockData)); + assertEquals(1, predictionSet.getPredictionCount()); + final Prediction prediction = predictionSet.getPrediction(0); + assertEquals("Potato", prediction.getPrediction()); + assertEquals(1, prediction.getDataCount()); + assertEquals("key0", prediction.getData(0).getKey()); + assertEquals(20d, prediction.getData(0).getValue(), 0); + } + @Test public void toDistinctListOfPairValues_withInputData_returnsExpectedDistinctListOfPairValues() { List, String>> mockData = Arrays.asList( From 965501579fd094486480149b6c4a6301563429c3 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 12:31:49 +0100 Subject: [PATCH 5/9] Deprecated old Kernel::fit --- src/main/java/de/dmi3y/behaiv/kernel/Kernel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java index b2db896..3535129 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java @@ -11,6 +11,7 @@ public interface Kernel { boolean isEmpty(); + @Deprecated void fit(List, String>> data); void fit(); From a2066c3cf4fd8acec4863a5cbebb14ef35e118d0 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 19:44:51 +0100 Subject: [PATCH 6/9] Refactored Behaiv to use PredictionSet instead of lists --- .../de/dmi3y/behaiv/kernel/BaseKernel.java | 37 ++++--- .../java/de/dmi3y/behaiv/kernel/Kernel.java | 3 + .../kernel/LogisticRegressionKernel.java | 85 ++++++++++++---- .../dmi3y/behaiv/tools/DataMappingUtils.java | 27 ++++-- .../java/tech/donau/behaiv/proto/Behaiv.java | 27 +++--- .../tech/donau/behaiv/proto/Prediction.java | 96 +++++++++---------- .../behaiv/proto/PredictionOrBuilder.java | 12 +-- .../donau/behaiv/proto/PredictionSet.java | 63 ++++++++++++ .../behaiv/proto/PredictionSetOrBuilder.java | 6 ++ .../de/dmi3y/behaiv/kernel/KernelTest.java | 10 +- .../kernel/LogisticRegressionKernelTest.java | 9 +- .../behaiv/tools/DataMappingUtilsTest.java | 13 ++- 12 files changed, 263 insertions(+), 125 deletions(-) diff --git a/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java b/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java index 04ef86b..e2a4bb5 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/BaseKernel.java @@ -1,14 +1,14 @@ package de.dmi3y.behaiv.kernel; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import de.dmi3y.behaiv.storage.BehaivStorage; import de.dmi3y.behaiv.tools.Pair; +import tech.donau.behaiv.proto.Data; +import tech.donau.behaiv.proto.Prediction; +import tech.donau.behaiv.proto.PredictionSet; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -34,7 +34,7 @@ public void setId(String id) { //list, label - protected List, String>> data = new ArrayList<>(); + protected PredictionSet data = PredictionSet.newBuilder().addAllPrediction(new ArrayList()).build(); @Override @@ -49,7 +49,7 @@ public void setTreshold(Long treshold) { @Override public boolean readyToPredict() { - return data.size() > treshold; + return data.getPredictionList().size() > treshold; } @Override @@ -63,7 +63,12 @@ public boolean isPartialFitAllowed() { @Override public void updateSingle(List features, String label) { - data.add(new Pair<>(features, label)); + final Prediction.Builder predictionBuilder = Prediction.newBuilder(); + for (int i = 0; i < features.size(); i++) { + predictionBuilder.addData(Data.newBuilder().setKey("key" + i).setValue(features.get(i)).build()); + } + predictionBuilder.setLabel(label); + data = data.toBuilder().addPrediction(predictionBuilder.build()).build(); } @Override @@ -78,23 +83,15 @@ public void setAlwaysKeepData(boolean alwaysKeepData) { @Override public void save(BehaivStorage storage) throws IOException { - - try (final BufferedWriter writer = new BufferedWriter(new FileWriter(storage.getDataFile(id)))) { - writer.write(objectMapper.writeValueAsString(data)); + try (final FileOutputStream writer = new FileOutputStream(storage.getDataFile(id))) { + data.writeTo(writer); } } @Override public void restore(BehaivStorage storage) throws IOException { - final TypeReference, String>>> typeReference = new TypeReference, String>>>() { - }; - try (final BufferedReader reader = new BufferedReader(new FileReader(storage.getDataFile(id)))) { - final String content = reader.readLine(); - if (content == null || content.isEmpty()) { - data = new ArrayList<>(); - } else { - data = objectMapper.readValue(content, typeReference); - } + try (final FileInputStream reader = new FileInputStream(storage.getDataFile(id))) { + data = PredictionSet.parseFrom(reader); } } } diff --git a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java index 3535129..8f915fa 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/Kernel.java @@ -2,6 +2,7 @@ import de.dmi3y.behaiv.storage.BehaivStorage; import de.dmi3y.behaiv.tools.Pair; +import tech.donau.behaiv.proto.PredictionSet; import java.io.IOException; import java.util.List; @@ -14,6 +15,8 @@ public interface Kernel { @Deprecated void fit(List, String>> data); + void fit(PredictionSet data); + void fit(); void setTreshold(Long treshold); diff --git a/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java b/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java index 3337192..f15a9e6 100644 --- a/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java +++ b/src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java @@ -3,23 +3,27 @@ import com.fasterxml.jackson.core.type.TypeReference; import de.dmi3y.behaiv.kernel.logistic.LogisticUtils; import de.dmi3y.behaiv.storage.BehaivStorage; +import de.dmi3y.behaiv.tools.DataMappingUtils; import de.dmi3y.behaiv.tools.Pair; import org.apache.commons.lang3.ArrayUtils; import org.ejml.simple.SimpleMatrix; +import tech.donau.behaiv.proto.PredictionSet; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; import static de.dmi3y.behaiv.tools.DataMappingUtils.toDistinctListOfPairValues; import static de.dmi3y.behaiv.tools.DataMappingUtils.toInput2dArray; public class LogisticRegressionKernel extends BaseKernel { - protected List labels = new ArrayList<>(); + protected List cachedLables = new ArrayList<>(); private Random rand; protected SimpleMatrix theta; @@ -35,24 +39,64 @@ public LogisticRegressionKernel(String id) { @Override public boolean isEmpty() { - return theta == null && data.size() == 0; + return theta == null && data.getPredictionCount() == 0; } - @Override - public void fit(List, String>> data) { + public void fit(PredictionSet data) { this.data = data; - labels = toDistinctListOfPairValues(data); + if (data.getDynamicColumns()) { + throw new UnsupportedOperationException("LogisticRegressionKernel doesn't support dynamic fields"); + } + for (int i = 0; i < data.getPredictionList().size(); i++) { + cachedLables.add(data.getPredictionList().get(i).getLabel()); + } if (readyToPredict()) { + //features + double[][] inputs = toInput2dArray(data); + + //labels + double[][] labelArray = new double[data.getPredictionCount()][cachedLables.size()]; + for (int i = 0; i < data.getPredictionCount(); i++) { + int dummyPos = cachedLables.indexOf(data.getPrediction(i).getLabel()); + labelArray[i][dummyPos] = 1.0; + } + + //output layer + final SimpleMatrix inputMatrix = new SimpleMatrix(inputs); + final SimpleMatrix outputMatrix = new SimpleMatrix(labelArray); + //3x4? + + //TODO dilemma on if we need to re-do theta or keep it as-is, if new features arrising we'll have a problem + if (theta == null || (theta.numCols() != cachedLables.size() && alwaysKeepData)) { + theta = SimpleMatrix.random_DDRM(inputMatrix.numCols(), outputMatrix.numCols(), 0, 1, rand); + } else if (theta.numCols() != cachedLables.size() && !alwaysKeepData) { + throw new UnsupportedOperationException( + "Partial fit of LogisticRegressionKernel is not supported. " + + "Number of labels differs from trained model." + + " Consider setting alwaysKeepData to true or changing Kernel that supports partial fit." + ); + } + + for (int i = 0; i < 10000; i++) { + theta = LogisticUtils.gradientDescent(inputMatrix, theta, outputMatrix, 0.1); + } + } + } + @Override + public void fit(List, String>> data) { + this.data = DataMappingUtils.createPredictionSet(data); + this.cachedLables = toDistinctListOfPairValues(data); + if (readyToPredict()) { //features double[][] inputs = toInput2dArray(data); //labels - double[][] labelArray = new double[data.size()][labels.size()]; + double[][] labelArray = new double[data.size()][cachedLables.size()]; for (int i = 0; i < data.size(); i++) { - int dummyPos = labels.indexOf(data.get(i).getValue()); + int dummyPos = cachedLables.indexOf(data.get(i).getValue()); labelArray[i][dummyPos] = 1.0; } @@ -62,9 +106,9 @@ public void fit(List, String>> data) { //3x4? //TODO dilemma on if we need to re-do theta or keep it as-is, if new features arrising we'll have a problem - if (theta == null || (theta.numCols() != labels.size() && alwaysKeepData)) { + if (theta == null || (theta.numCols() != cachedLables.size() && alwaysKeepData)) { theta = SimpleMatrix.random_DDRM(inputMatrix.numCols(), outputMatrix.numCols(), 0, 1, rand); - } else if (theta.numCols() != labels.size() && !alwaysKeepData) { + } else if (theta.numCols() != cachedLables.size() && !alwaysKeepData) { throw new UnsupportedOperationException( "Partial fit of LogisticRegressionKernel is not supported. " + "Number of labels differs from trained model." + @@ -92,8 +136,6 @@ public void updateSingle(List features, String label) { @Override public String predictOne(List features) { - - final double[] doubles = ArrayUtils.toPrimitive(features.toArray(new Double[0])); final SimpleMatrix inputs = new SimpleMatrix(new double[][]{doubles}); @@ -106,18 +148,21 @@ public String predictOne(List features) { maxPosition = i; } } - return labels.get(maxPosition); + return cachedLables.get(maxPosition); } @Override public void save(BehaivStorage storage) throws IOException { - if (theta == null && (data == null || data.isEmpty())) { + if (theta == null && (data == null || data.getPredictionList().isEmpty())) { throw new IOException("Not enough data to save, network data is empty"); } - if(labels == null || labels.isEmpty()) { - labels = toDistinctListOfPairValues(data); + if (cachedLables == null || cachedLables.isEmpty()) { + cachedLables = new ArrayList<>(); + for (int i = 0; i < data.getPredictionList().size(); i++) { + cachedLables.add(data.getPredictionList().get(i).getLabel()); + } } - if (labels.isEmpty()) { + if (cachedLables.isEmpty()) { String message; message = "Kernel collected data but failed to get labels, couldn't save network."; throw new IOException(message); @@ -131,7 +176,7 @@ public void save(BehaivStorage storage) throws IOException { theta.saveToFileBinary(storage.getNetworkFile(id).toString()); try (final BufferedWriter writer = new BufferedWriter(new FileWriter(storage.getNetworkMetadataFile(id)))) { - writer.write(objectMapper.writeValueAsString(labels)); + writer.write(objectMapper.writeValueAsString(cachedLables)); } catch (Exception e) { e.printStackTrace(); } @@ -157,9 +202,9 @@ public void restore(BehaivStorage storage) throws IOException { }; final String labelsData = reader.readLine(); if (labelsData == null) { - labels = new ArrayList<>(); + cachedLables = new ArrayList<>(); } else { - labels = objectMapper.readValue(labelsData, typeReference); + cachedLables = objectMapper.readValue(labelsData, typeReference); } } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java b/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java index 718b98a..94cc1d7 100644 --- a/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java +++ b/src/main/java/de/dmi3y/behaiv/tools/DataMappingUtils.java @@ -10,8 +10,7 @@ import java.util.List; import java.util.Set; -public final class DataMappingUtils -{ +public final class DataMappingUtils { private DataMappingUtils() { // Unused utility class @@ -23,21 +22,21 @@ public static PredictionSet createPredictionSet(List, String>> final List weights = data.get(i).getKey(); final ArrayList row = new ArrayList<>(); for (int j = 0; j < weights.size(); j++) { - row.add(Data.newBuilder().setKey("key"+j).setValue(weights.get(j)).build()); + row.add(Data.newBuilder().setKey("key" + j).setValue(weights.get(j)).build()); } predictionSetBuilder.addPrediction( Prediction.newBuilder() .addAllData(row) - .setPrediction(data.get(i).getValue()) + .setLabel(data.get(i).getValue()) .build() ); } - return predictionSetBuilder.build(); + return predictionSetBuilder.buildPartial(); } public static List toDistinctListOfPairValues(List, String>> data) { Set setOfValues = new HashSet<>(); - for(Pair, String> arrayListStringPair : data ) { + for (Pair, String> arrayListStringPair : data) { setOfValues.add(arrayListStringPair.getValue()); } return new ArrayList<>(setOfValues); @@ -62,4 +61,20 @@ public static double[][] toInput2dArray(List, String>> data) { return input2dArray; } + public static double[][] toInput2dArray(PredictionSet data) { + double[][] input2dArray = new double[data.getPredictionCount()][]; + final List predictionList = data.getPredictionList(); + for (int i = 0; i < predictionList.size(); i++) { + final Prediction prediction = predictionList.get(i); + final List row = prediction.getDataList(); + final double[] doubleRow = new double[row.size()]; + for (int j = 0; j < row.size(); j++) { + doubleRow[j] = row.get(j).getValue(); + } + input2dArray[i] = doubleRow; + } + + return input2dArray; + } + } diff --git a/src/main/java/tech/donau/behaiv/proto/Behaiv.java b/src/main/java/tech/donau/behaiv/proto/Behaiv.java index 7c5bde9..7b718d0 100644 --- a/src/main/java/tech/donau/behaiv/proto/Behaiv.java +++ b/src/main/java/tech/donau/behaiv/proto/Behaiv.java @@ -54,17 +54,18 @@ public static void registerAllExtensions( static { java.lang.String[] descriptorData = { "\n\014behaiv.proto\"(\n\004Data\022\013\n\003key\030\002 \001(\t\022\r\n\005v" + - "alue\030\003 \001(\001J\004\010\001\020\002\"5\n\nPrediction\022\023\n\004data\030\001" + - " \003(\0132\005.Data\022\022\n\nprediction\030\002 \001(\t\"0\n\rPredi" + - "ctionSet\022\037\n\nprediction\030\001 \003(\0132\013.Predictio" + - "n\"\342\001\n\006Action\022\020\n\010local_id\030\001 \001(\003\022\025\n\rprev_l" + - "ocal_id\030\002 \001(\003\022\016\n\006action\030\003 \001(\t\022\016\n\006object\030" + - "\004 \001(\t\022\031\n\021current_screen_id\030\005 \001(\005\022\024\n\014scre" + - "en_stack\030\006 \003(\005\022+\n\nattributes\030\010 \003(\0132\027.Act" + - "ion.AttributesEntry\0321\n\017AttributesEntry\022\013" + - "\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\"\n\006Screen" + - "\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030\002 \001(\tB\033\n\027tech.donau" + - ".behaiv.protoP\001b\006proto3" + "alue\030\003 \001(\001J\004\010\001\020\002\"0\n\nPrediction\022\023\n\004data\030\001" + + " \003(\0132\005.Data\022\r\n\005label\030\002 \001(\t\"H\n\rPrediction" + + "Set\022\037\n\nprediction\030\001 \003(\0132\013.Prediction\022\026\n\016" + + "dynamicColumns\030\002 \001(\010\"\342\001\n\006Action\022\020\n\010local" + + "_id\030\001 \001(\003\022\025\n\rprev_local_id\030\002 \001(\003\022\016\n\006acti" + + "on\030\003 \001(\t\022\016\n\006object\030\004 \001(\t\022\031\n\021current_scre" + + "en_id\030\005 \001(\005\022\024\n\014screen_stack\030\006 \003(\005\022+\n\natt" + + "ributes\030\010 \003(\0132\027.Action.AttributesEntry\0321" + + "\n\017AttributesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030" + + "\002 \001(\t:\0028\001\"\"\n\006Screen\022\n\n\002id\030\001 \001(\005\022\014\n\004name\030" + + "\002 \001(\tB\033\n\027tech.donau.behaiv.protoP\001b\006prot" + + "o3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -81,13 +82,13 @@ public static void registerAllExtensions( internal_static_Prediction_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_Prediction_descriptor, - new java.lang.String[] { "Data", "Prediction", }); + new java.lang.String[] { "Data", "Label", }); internal_static_PredictionSet_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_PredictionSet_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_PredictionSet_descriptor, - new java.lang.String[] { "Prediction", }); + new java.lang.String[] { "Prediction", "DynamicColumns", }); internal_static_Action_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_Action_fieldAccessorTable = new diff --git a/src/main/java/tech/donau/behaiv/proto/Prediction.java b/src/main/java/tech/donau/behaiv/proto/Prediction.java index a257ce7..c7188c3 100644 --- a/src/main/java/tech/donau/behaiv/proto/Prediction.java +++ b/src/main/java/tech/donau/behaiv/proto/Prediction.java @@ -17,7 +17,7 @@ private Prediction(com.google.protobuf.GeneratedMessageV3.Builder builder) { } private Prediction() { data_ = java.util.Collections.emptyList(); - prediction_ = ""; + label_ = ""; } @java.lang.Override @@ -63,7 +63,7 @@ private Prediction( case 18: { java.lang.String s = input.readStringRequireUtf8(); - prediction_ = s; + label_ = s; break; } default: { @@ -136,36 +136,36 @@ public tech.donau.behaiv.proto.DataOrBuilder getDataOrBuilder( return data_.get(index); } - public static final int PREDICTION_FIELD_NUMBER = 2; - private volatile java.lang.Object prediction_; + public static final int LABEL_FIELD_NUMBER = 2; + private volatile java.lang.Object label_; /** - * string prediction = 2; - * @return The prediction. + * string label = 2; + * @return The label. */ - public java.lang.String getPrediction() { - java.lang.Object ref = prediction_; + public java.lang.String getLabel() { + java.lang.Object ref = label_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - prediction_ = s; + label_ = s; return s; } } /** - * string prediction = 2; - * @return The bytes for prediction. + * string label = 2; + * @return The bytes for label. */ public com.google.protobuf.ByteString - getPredictionBytes() { - java.lang.Object ref = prediction_; + getLabelBytes() { + java.lang.Object ref = label_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - prediction_ = b; + label_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; @@ -189,8 +189,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < data_.size(); i++) { output.writeMessage(1, data_.get(i)); } - if (!getPredictionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, prediction_); + if (!getLabelBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, label_); } unknownFields.writeTo(output); } @@ -205,8 +205,8 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, data_.get(i)); } - if (!getPredictionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, prediction_); + if (!getLabelBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, label_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -225,8 +225,8 @@ public boolean equals(final java.lang.Object obj) { if (!getDataList() .equals(other.getDataList())) return false; - if (!getPrediction() - .equals(other.getPrediction())) return false; + if (!getLabel() + .equals(other.getLabel())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -242,8 +242,8 @@ public int hashCode() { hash = (37 * hash) + DATA_FIELD_NUMBER; hash = (53 * hash) + getDataList().hashCode(); } - hash = (37 * hash) + PREDICTION_FIELD_NUMBER; - hash = (53 * hash) + getPrediction().hashCode(); + hash = (37 * hash) + LABEL_FIELD_NUMBER; + hash = (53 * hash) + getLabel().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -384,7 +384,7 @@ public Builder clear() { } else { dataBuilder_.clear(); } - prediction_ = ""; + label_ = ""; return this; } @@ -422,7 +422,7 @@ public tech.donau.behaiv.proto.Prediction buildPartial() { } else { result.data_ = dataBuilder_.build(); } - result.prediction_ = prediction_; + result.label_ = label_; onBuilt(); return result; } @@ -497,8 +497,8 @@ public Builder mergeFrom(tech.donau.behaiv.proto.Prediction other) { } } } - if (!other.getPrediction().isEmpty()) { - prediction_ = other.prediction_; + if (!other.getLabel().isEmpty()) { + label_ = other.label_; onChanged(); } this.mergeUnknownFields(other.unknownFields); @@ -771,78 +771,78 @@ public tech.donau.behaiv.proto.Data.Builder addDataBuilder( return dataBuilder_; } - private java.lang.Object prediction_ = ""; + private java.lang.Object label_ = ""; /** - * string prediction = 2; - * @return The prediction. + * string label = 2; + * @return The label. */ - public java.lang.String getPrediction() { - java.lang.Object ref = prediction_; + public java.lang.String getLabel() { + java.lang.Object ref = label_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); - prediction_ = s; + label_ = s; return s; } else { return (java.lang.String) ref; } } /** - * string prediction = 2; - * @return The bytes for prediction. + * string label = 2; + * @return The bytes for label. */ public com.google.protobuf.ByteString - getPredictionBytes() { - java.lang.Object ref = prediction_; + getLabelBytes() { + java.lang.Object ref = label_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); - prediction_ = b; + label_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** - * string prediction = 2; - * @param value The prediction to set. + * string label = 2; + * @param value The label to set. * @return This builder for chaining. */ - public Builder setPrediction( + public Builder setLabel( java.lang.String value) { if (value == null) { throw new NullPointerException(); } - prediction_ = value; + label_ = value; onChanged(); return this; } /** - * string prediction = 2; + * string label = 2; * @return This builder for chaining. */ - public Builder clearPrediction() { + public Builder clearLabel() { - prediction_ = getDefaultInstance().getPrediction(); + label_ = getDefaultInstance().getLabel(); onChanged(); return this; } /** - * string prediction = 2; - * @param value The bytes for prediction to set. + * string label = 2; + * @param value The bytes for label to set. * @return This builder for chaining. */ - public Builder setPredictionBytes( + public Builder setLabelBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); - prediction_ = value; + label_ = value; onChanged(); return this; } diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java index db9546a..740e6ae 100644 --- a/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java +++ b/src/main/java/tech/donau/behaiv/proto/PredictionOrBuilder.java @@ -32,14 +32,14 @@ tech.donau.behaiv.proto.DataOrBuilder getDataOrBuilder( int index); /** - * string prediction = 2; - * @return The prediction. + * string label = 2; + * @return The label. */ - java.lang.String getPrediction(); + java.lang.String getLabel(); /** - * string prediction = 2; - * @return The bytes for prediction. + * string label = 2; + * @return The bytes for label. */ com.google.protobuf.ByteString - getPredictionBytes(); + getLabelBytes(); } diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionSet.java b/src/main/java/tech/donau/behaiv/proto/PredictionSet.java index bc2fb05..6e11bf1 100644 --- a/src/main/java/tech/donau/behaiv/proto/PredictionSet.java +++ b/src/main/java/tech/donau/behaiv/proto/PredictionSet.java @@ -59,6 +59,11 @@ private PredictionSet( input.readMessage(tech.donau.behaiv.proto.Prediction.parser(), extensionRegistry)); break; } + case 16: { + + dynamicColumns_ = input.readBool(); + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -129,6 +134,16 @@ public tech.donau.behaiv.proto.PredictionOrBuilder getPredictionOrBuilder( return prediction_.get(index); } + public static final int DYNAMICCOLUMNS_FIELD_NUMBER = 2; + private boolean dynamicColumns_; + /** + * bool dynamicColumns = 2; + * @return The dynamicColumns. + */ + public boolean getDynamicColumns() { + return dynamicColumns_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -146,6 +161,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < prediction_.size(); i++) { output.writeMessage(1, prediction_.get(i)); } + if (dynamicColumns_ != false) { + output.writeBool(2, dynamicColumns_); + } unknownFields.writeTo(output); } @@ -159,6 +177,10 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, prediction_.get(i)); } + if (dynamicColumns_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, dynamicColumns_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -176,6 +198,8 @@ public boolean equals(final java.lang.Object obj) { if (!getPredictionList() .equals(other.getPredictionList())) return false; + if (getDynamicColumns() + != other.getDynamicColumns()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -191,6 +215,9 @@ public int hashCode() { hash = (37 * hash) + PREDICTION_FIELD_NUMBER; hash = (53 * hash) + getPredictionList().hashCode(); } + hash = (37 * hash) + DYNAMICCOLUMNS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getDynamicColumns()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -331,6 +358,8 @@ public Builder clear() { } else { predictionBuilder_.clear(); } + dynamicColumns_ = false; + return this; } @@ -367,6 +396,7 @@ public tech.donau.behaiv.proto.PredictionSet buildPartial() { } else { result.prediction_ = predictionBuilder_.build(); } + result.dynamicColumns_ = dynamicColumns_; onBuilt(); return result; } @@ -441,6 +471,9 @@ public Builder mergeFrom(tech.donau.behaiv.proto.PredictionSet other) { } } } + if (other.getDynamicColumns() != false) { + setDynamicColumns(other.getDynamicColumns()); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -710,6 +743,36 @@ public tech.donau.behaiv.proto.Prediction.Builder addPredictionBuilder( } return predictionBuilder_; } + + private boolean dynamicColumns_ ; + /** + * bool dynamicColumns = 2; + * @return The dynamicColumns. + */ + public boolean getDynamicColumns() { + return dynamicColumns_; + } + /** + * bool dynamicColumns = 2; + * @param value The dynamicColumns to set. + * @return This builder for chaining. + */ + public Builder setDynamicColumns(boolean value) { + + dynamicColumns_ = value; + onChanged(); + return this; + } + /** + * bool dynamicColumns = 2; + * @return This builder for chaining. + */ + public Builder clearDynamicColumns() { + + dynamicColumns_ = false; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java b/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java index 8252e1d..745e30e 100644 --- a/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java +++ b/src/main/java/tech/donau/behaiv/proto/PredictionSetOrBuilder.java @@ -30,4 +30,10 @@ public interface PredictionSetOrBuilder extends */ tech.donau.behaiv.proto.PredictionOrBuilder getPredictionOrBuilder( int index); + + /** + * bool dynamicColumns = 2; + * @return The dynamicColumns. + */ + boolean getDynamicColumns(); } diff --git a/src/test/java/de/dmi3y/behaiv/kernel/KernelTest.java b/src/test/java/de/dmi3y/behaiv/kernel/KernelTest.java index 78cde5f..cf1d1bd 100644 --- a/src/test/java/de/dmi3y/behaiv/kernel/KernelTest.java +++ b/src/test/java/de/dmi3y/behaiv/kernel/KernelTest.java @@ -6,6 +6,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import tech.donau.behaiv.proto.Data; +import tech.donau.behaiv.proto.Prediction; import java.io.File; import java.io.IOException; @@ -40,8 +42,12 @@ public void setUp() throws Exception { @Test public void setTreshold() { dummyKernel.setTreshold(1L); - dummyKernel.data.add(new Pair, String>(null, null)); - dummyKernel.data.add(new Pair, String>(null, null)); + final Prediction prediction = Prediction.newBuilder().addData( + Data.newBuilder().setKey("null").setValue(0.0D).build() + ).addData( + Data.newBuilder().setKey("null2").setValue(0.0D).build()).build(); + dummyKernel.data = dummyKernel.data.toBuilder() + .addPrediction(prediction).addPrediction(prediction).build(); boolean readyToPredict = dummyKernel.readyToPredict(); assertTrue(readyToPredict); dummyKernel.setTreshold(10L); diff --git a/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java b/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java index 1a6fdf4..bc6bef2 100644 --- a/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java +++ b/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java @@ -1,6 +1,7 @@ package de.dmi3y.behaiv.kernel; import de.dmi3y.behaiv.storage.SimpleStorage; +import de.dmi3y.behaiv.tools.DataMappingUtils; import de.dmi3y.behaiv.tools.Pair; import org.junit.Before; import org.junit.Rule; @@ -15,7 +16,6 @@ import static de.dmi3y.behaiv.kernel.KernelTest.HOME; import static de.dmi3y.behaiv.kernel.KernelTest.WORK; -import static de.dmi3y.behaiv.kernel.KernelTest.getTrainingData; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -145,8 +145,8 @@ public void storeResults_saveWhenDataIsNull_expectException() throws IOException public void storeResults_saveDataAndThenTheta_expectNormalFlow() throws IOException, ClassNotFoundException { List, String>> data = KernelTest.getTrainingData(); LogisticRegressionKernel kernel = new LogisticRegressionKernel("storeTest", new Random()); - kernel.data = data; - kernel.labels = Arrays.asList("time", "lat", "lon", "headphones"); + kernel.data = DataMappingUtils.createPredictionSet(data); + kernel.cachedLables = Arrays.asList("time", "lat", "lon", "headphones"); //Omit fit // kernel.fit(data); ArrayList predictList = new ArrayList<>(); @@ -161,8 +161,7 @@ public void storeResults_saveDataAndThenTheta_expectNormalFlow() throws IOExcept kernel = new LogisticRegressionKernel("storeTest"); kernel.restore(storage); - assertFalse(kernel.data.isEmpty()); - kernel.data.get(0).getKey(); + assertFalse(kernel.data.getPredictionList().isEmpty()); kernel.fit(data); String prediction = kernel.predictOne(predictList); diff --git a/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java b/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java index f9f5f50..3468804 100644 --- a/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java +++ b/src/test/java/de/dmi3y/behaiv/tools/DataMappingUtilsTest.java @@ -1,7 +1,6 @@ package de.dmi3y.behaiv.tools; import org.junit.Test; -import org.mockito.internal.matchers.Null; import tech.donau.behaiv.proto.Prediction; import tech.donau.behaiv.proto.PredictionSet; @@ -10,8 +9,12 @@ import java.util.Collections; import java.util.List; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class DataMappingUtilsTest { @@ -22,7 +25,7 @@ public void createPredictionSet_feedDefaultTestData_expectCorrectOrder() { final PredictionSet predictionSet = DataMappingUtils.createPredictionSet(Collections.singletonList(mockData)); assertEquals(1, predictionSet.getPredictionCount()); final Prediction prediction = predictionSet.getPrediction(0); - assertEquals("Potato", prediction.getPrediction()); + assertEquals("Potato", prediction.getLabel()); assertEquals(1, prediction.getDataCount()); assertEquals("key0", prediction.getData(0).getKey()); assertEquals(20d, prediction.getData(0).getValue(), 0); @@ -88,7 +91,7 @@ public void toInput2dArray_withEmptyListOfInputData_returnsEmpty2dArray() { @Test(expected = NullPointerException.class) public void toInput2dArray_withNull_throwsNullPointerException() { - DataMappingUtils.toInput2dArray(null); + DataMappingUtils.toInput2dArray((List, String>>) null); } From 65b24f3356f867c1629842517536f3a3ca54d233 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 19:53:29 +0100 Subject: [PATCH 7/9] Ignore tech.donau.behaiv.proto package on jacoco reports --- build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.gradle b/build.gradle index cec6e41..1ccdb32 100644 --- a/build.gradle +++ b/build.gradle @@ -80,6 +80,11 @@ jacocoTestReport { xml.enabled = true csv.enabled = false } + afterEvaluate { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: 'tech/donau/behaiv/proto**') + })) + } } task proto(type: Exec) { From a90946394b6f301ce34f44866bedc0621351fac5 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 19:57:15 +0100 Subject: [PATCH 8/9] Removed unused empty constructor in Pair.java --- src/main/java/de/dmi3y/behaiv/tools/Pair.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/de/dmi3y/behaiv/tools/Pair.java b/src/main/java/de/dmi3y/behaiv/tools/Pair.java index da0fe93..9cd9b98 100644 --- a/src/main/java/de/dmi3y/behaiv/tools/Pair.java +++ b/src/main/java/de/dmi3y/behaiv/tools/Pair.java @@ -14,9 +14,6 @@ public Pair(de.dmi3y.behaiv.tools.Pair entry) { this(entry.getKey(), entry.getValue()); } - public Pair() { - } - public K getKey() { return this.key; } From 2eea223471a2afdad0c6f9e1b439c520258f81f3 Mon Sep 17 00:00:00 2001 From: dmi3coder Date: Sat, 7 Mar 2020 20:03:36 +0100 Subject: [PATCH 9/9] added test for LogisticRegressionKernel to check if partial fit is allowed --- .../dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java b/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java index bc6bef2..2157575 100644 --- a/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java +++ b/src/test/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernelTest.java @@ -57,6 +57,12 @@ public void predictOne() { assertEquals("SELFIMPROVEMENT_SCREEN", prediction); } + @Test + public void isPartialFitAllowed_inLogisticRegression_shouldReturnFalse() { + final Kernel kernel = new LogisticRegressionKernel("testId"); + assertFalse(kernel.isPartialFitAllowed()); + } + @Test public void storeResults() throws IOException, ClassNotFoundException { List, String>> data = KernelTest.getTrainingData();