kz.greetgo.kafka.model.Box Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of greetgo.kafka-model Show documentation
Show all versions of greetgo.kafka-model Show documentation
Kafka greetgo library for kafka models
package kz.greetgo.kafka.model;
import java.util.Collection;
public class Box {
/**
* Author of record
*/
public String a;
/**
* Kafka id
*/
public String id;
/**
* Body of message
*/
public Object body;
@Override
public String toString() {
StringBuilder ret = new StringBuilder();
ret.append("Box{");
if (a != null) {
ret.append("a=").append(a);
}
if (id != null) {
ret.append("id=").append(id);
}
ret.append("body=").append(body);
ret.append('}');
return ret.toString();
}
public static void validateBody(Object body) throws Throwable {
if (body == null) {
throw new NullPointerException(Box.class.getName() + ".body == null");
}
if (body instanceof KafkaValidator) {
((KafkaValidator) body).validateKafka();
return;
}
if (body instanceof Collection) {
//noinspection rawtypes
for (Object object : ((Collection) body)) {
validateIt(object);
}
return;
}
}
public void validate() throws Throwable {
validateBody(body);
}
private static void validateIt(Object object) throws Throwable {
if (object instanceof KafkaValidator) {
((KafkaValidator) object).validateKafka();
}
}
}