Home / Class/ ProtocolDetectionResult Class — netty Architecture

ProtocolDetectionResult Class — netty Architecture

Architecture documentation for the ProtocolDetectionResult class in ProtocolDetectionResult.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639["ProtocolDetectionResult"]
  14066293_fe90_11a2_2cd9_49586e0ffb12["ProtocolDetectionResult.java"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|defined in| 14066293_fe90_11a2_2cd9_49586e0ffb12
  b3dc550e_e670_940d_57ec_88ee13f22237["needsMoreData()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| b3dc550e_e670_940d_57ec_88ee13f22237
  b1aff2a0_c3b2_e879_fbbb_1004ddc51feb["invalid()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| b1aff2a0_c3b2_e879_fbbb_1004ddc51feb
  cc512cb2_f20f_211e_f3d5_61a7264700a8["detected()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| cc512cb2_f20f_211e_f3d5_61a7264700a8
  826616f8_56ef_dae5_901b_25c9fb6e8b0c["ProtocolDetectionResult()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| 826616f8_56ef_dae5_901b_25c9fb6e8b0c
  609bc487_8db3_e2e6_8a42_a9f0429e21a2["ProtocolDetectionState()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| 609bc487_8db3_e2e6_8a42_a9f0429e21a2
  9801a8e5_b5dd_f0a0_8c38_d7f18f8eed2e["T()"]
  fd233bd4_5d4b_ee69_a4e0_37007d7f2639 -->|method| 9801a8e5_b5dd_f0a0_8c38_d7f18f8eed2e

Relationship Graph

Source Code

codec-base/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java lines 25–80

public final class ProtocolDetectionResult<T> {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    private static final ProtocolDetectionResult NEEDS_MORE_DATA =
            new ProtocolDetectionResult(ProtocolDetectionState.NEEDS_MORE_DATA, null);
    @SuppressWarnings({ "rawtypes", "unchecked" })
    private static final ProtocolDetectionResult INVALID =
            new ProtocolDetectionResult(ProtocolDetectionState.INVALID, null);

    private final ProtocolDetectionState state;
    private final T result;

    /**
     * Returns a {@link ProtocolDetectionResult} that signals that more data is needed to detect the protocol.
     */
    @SuppressWarnings("unchecked")
    public static <T> ProtocolDetectionResult<T> needsMoreData() {
        return NEEDS_MORE_DATA;
    }

    /**
     * Returns a {@link ProtocolDetectionResult} that signals the data was invalid for the protocol.
     */
    @SuppressWarnings("unchecked")
    public static <T> ProtocolDetectionResult<T> invalid() {
        return INVALID;
    }

    /**
     * Returns a {@link ProtocolDetectionResult} which holds the detected protocol.
     */
    @SuppressWarnings("unchecked")
    public static <T> ProtocolDetectionResult<T> detected(T protocol) {
        return new ProtocolDetectionResult<T>(ProtocolDetectionState.DETECTED, checkNotNull(protocol, "protocol"));
    }

    private ProtocolDetectionResult(ProtocolDetectionState state, T result) {
        this.state = state;
        this.result = result;
    }

    /**
     * Return the {@link ProtocolDetectionState}. If the state is {@link ProtocolDetectionState#DETECTED} you
     * can retrieve the protocol via {@link #detectedProtocol()}.
     */
    public ProtocolDetectionState state() {
        return state;
    }

    /**
     * Returns the protocol if {@link #state()} returns {@link ProtocolDetectionState#DETECTED}, otherwise {@code null}.
     */
    public T detectedProtocol() {
        return result;
    }
}

Frequently Asked Questions

What is the ProtocolDetectionResult class?
ProtocolDetectionResult is a class in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java.
Where is ProtocolDetectionResult defined?
ProtocolDetectionResult is defined in codec-base/src/main/java/io/netty/handler/codec/ProtocolDetectionResult.java at line 25.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free