Skip to content

Commit b72fd61

Browse files
committed
Tighten up visibility
1 parent 025f07e commit b72fd61

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CommunityIdProcessor.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public String getType() {
255255
/**
256256
* Converts an integer in the range of an unsigned 16-bit integer to a big-endian byte pair
257257
*/
258+
// visible for testing
258259
static byte[] toUint16(int num) {
259260
if (num < 0 || num > 65535) {
260261
throw new IllegalStateException("number [" + num + "] must be a value between 0 and 65535");
@@ -265,7 +266,7 @@ static byte[] toUint16(int num) {
265266
/**
266267
* Attempts to coerce an object to an integer
267268
*/
268-
static int parseIntFromObjectOrString(Object o, String fieldName) {
269+
private static int parseIntFromObjectOrString(Object o, String fieldName) {
269270
if (o == null) {
270271
return 0;
271272
} else if (o instanceof Number number) {
@@ -336,7 +337,11 @@ public CommunityIdProcessor create(
336337
/**
337338
* Represents flow data per the <a href="https://github.com/corelight/community-id-spec">Community ID</a> spec.
338339
*/
339-
public static final class Flow {
340+
private static final class Flow {
341+
342+
private Flow() {
343+
// this is only constructable from inside this file
344+
}
340345

341346
private static final List<Transport.Type> TRANSPORTS_WITH_PORTS = List.of(
342347
Transport.Type.Tcp,
@@ -442,12 +447,12 @@ public int getTransportNumber() {
442447
private final Type type;
443448
private final int transportNumber;
444449

445-
Transport(int transportNumber, Type type) { // Change constructor to public
450+
private Transport(int transportNumber, Type type) {
446451
this.transportNumber = transportNumber;
447452
this.type = type;
448453
}
449454

450-
Transport(Type type) { // Change constructor to public
455+
private Transport(Type type) {
451456
this.transportNumber = type.getTransportNumber();
452457
this.type = type;
453458
}
@@ -460,7 +465,8 @@ public int getTransportNumber() {
460465
return transportNumber;
461466
}
462467

463-
public static Transport fromNumber(int transportNumber) {
468+
// visible for testing
469+
static Transport fromNumber(int transportNumber) {
464470
if (transportNumber < 0 || transportNumber >= 255) {
465471
// transport numbers range https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
466472
throw new IllegalArgumentException("invalid transport protocol number [" + transportNumber + "]");
@@ -483,7 +489,7 @@ public static Transport fromNumber(int transportNumber) {
483489
return new Transport(transportNumber, type);
484490
}
485491

486-
public static Transport fromObject(Object o) {
492+
private static Transport fromObject(Object o) {
487493
if (o instanceof Number number) {
488494
return fromNumber(number.intValue());
489495
} else if (o instanceof String protocolStr) {
@@ -599,7 +605,7 @@ public static IcmpType fromNumber(int type) {
599605
};
600606
}
601607

602-
public static Integer codeEquivalent(int icmpType, boolean isIpV6) {
608+
private static Integer codeEquivalent(int icmpType, boolean isIpV6) {
603609
return isIpV6 ? ICMP_V6_CODE_EQUIVALENTS.get(icmpType) : ICMP_V4_CODE_EQUIVALENTS.get(icmpType);
604610
}
605611
}

0 commit comments

Comments
 (0)