mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
21.09.2015 a4e4a5b2d484486dc143ea9cd963168b0668d2c0
Fix checkstyle for TransactionIdControl class
1 files modified
181 ■■■■ changed files
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/controls/TransactionIdControl.java 181 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/controls/TransactionIdControl.java
@@ -35,120 +35,105 @@
/**
 * Control to provide a transaction ID.
 * <p>
 * The transaction ID is related to Common Audit : it is used for tracking the
 * processing of a user-interaction as it passes through the Forgerock stack
 * The transaction ID is related to Common Audit : it is used for tracking the processing of a user-interaction as it
 * passes through the Forgerock stack
 * <p>
 * The control's value is the UTF-8 encoding of the transaction ID.
 */
public final class TransactionIdControl implements Control
{
public final class TransactionIdControl implements Control {
  /** OID for this control. */
  public static final String OID = "1.3.6.1.4.1.36733.2.1.5.1";
    /** OID for this control. */
    public static final String OID = "1.3.6.1.4.1.36733.2.1.5.1";
  /** A decoder which can be used for decoding the simple paged results control. */
  public static final ControlDecoder<TransactionIdControl> DECODER = new ControlDecoder<TransactionIdControl>()
  {
    /** A decoder which can be used for decoding the simple paged results control. */
    public static final ControlDecoder<TransactionIdControl> DECODER = new ControlDecoder<TransactionIdControl>() {
    @Override
    public TransactionIdControl decodeControl(final Control control, final DecodeOptions options)
        throws DecodeException
    {
      Reject.ifNull(control);
        @Override
        public TransactionIdControl decodeControl(final Control control, final DecodeOptions options)
                throws DecodeException {
            Reject.ifNull(control);
      if (control instanceof TransactionIdControl)
      {
        return (TransactionIdControl) control;
      }
            if (control instanceof TransactionIdControl) {
                return (TransactionIdControl) control;
            }
      if (!control.getOID().equals(OID))
      {
        throw DecodeException.error(ERR_TRANSACTION_ID_CONTROL_BAD_OID.get(control.getOID(), OID));
      }
            if (!control.getOID().equals(OID)) {
                throw DecodeException.error(ERR_TRANSACTION_ID_CONTROL_BAD_OID.get(control.getOID(), OID));
            }
      if (!control.hasValue())
      {
        // The control must always have a value.
        throw DecodeException.error(ERR_TRANSACTION_ID_CONTROL_DECODE_NULL.get());
      }
            if (!control.hasValue()) {
                // The control must always have a value.
                throw DecodeException.error(ERR_TRANSACTION_ID_CONTROL_DECODE_NULL.get());
            }
      return new TransactionIdControl(control.getValue().toString());
            return new TransactionIdControl(control.getValue().toString());
        }
        @Override
        public String getOID() {
            return OID;
        }
    };
    /**
     * Creates a new transactionId control.
     *
     * @param transactionId
     *            The transaction id to provide through this control.
     * @return The new control.
     * @throws NullPointerException
     *             If {@code transactionId} was {@code null}.
     */
    public static TransactionIdControl newControl(final String transactionId) {
        Reject.ifNull(transactionId);
        return new TransactionIdControl(transactionId);
    }
    /** The control value transactionId element. */
    private final String transactionId;
    private TransactionIdControl(final String transactionId) {
        this.transactionId = transactionId;
    }
    /**
     * Returns the transaction id.
     *
     * @return The transaction id.
     */
    public String getTransactionId() {
        return transactionId;
    }
    @Override
    public String getOID()
    {
      return OID;
    public String getOID() {
        return OID;
    }
  };
  /**
   * Creates a new transactionId control.
   *
   * @param transactionId
   *          The transaction id to provide through this control.
   * @return The new control.
   * @throws NullPointerException
   *           If {@code transactionId} was {@code null}.
   */
  public static TransactionIdControl newControl(final String transactionId)
  {
    Reject.ifNull(transactionId);
    return new TransactionIdControl(transactionId);
  }
    @Override
    public ByteString getValue() {
        return ByteString.valueOfUtf8(transactionId);
    }
  /** The control value transactionId element. */
  private final String transactionId;
    @Override
    public boolean hasValue() {
        return true;
    }
  private TransactionIdControl(final String transactionId)
  {
    this.transactionId = transactionId;
  }
    @Override
    public boolean isCritical() {
        // This control is never critical.
        return false;
    }
  /**
   * Returns the transaction id.
   *
   * @return The transaction id.
   */
  public String getTransactionId()
  {
    return transactionId;
  }
  @Override
  public String getOID()
  {
    return OID;
  }
  @Override
  public ByteString getValue()
  {
    return ByteString.valueOfUtf8(transactionId);
  }
  @Override
  public boolean hasValue()
  {
    return true;
  }
  @Override
  public boolean isCritical()
  {
    // This control is never critical.
    return false;
  }
  @Override
  public String toString()
  {
    final StringBuilder builder = new StringBuilder();
    builder.append("TransactionIdControl(oid=");
    builder.append(getOID());
    builder.append(", transactionId=");
    builder.append(transactionId);
    builder.append(")");
    return builder.toString();
  }
    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
        builder.append("TransactionIdControl(oid=");
        builder.append(getOID());
        builder.append(", transactionId=");
        builder.append(transactionId);
        builder.append(")");
        return builder.toString();
    }
}