< prev index next >

src/java.base/share/classes/javax/security/auth/callback/TextOutputCallback.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  57     private String message;
  58 
  59     /**
  60      * Construct a TextOutputCallback with a message type and message
  61      * to be displayed.
  62      *
  63      * @param messageType the message type ({@code INFORMATION},
  64      *                  {@code WARNING} or {@code ERROR}).
  65      *
  66      * @param message the message to be displayed.
  67      *
  68      * @exception IllegalArgumentException if {@code messageType}
  69      *                  is not either {@code INFORMATION},
  70      *                  {@code WARNING} or {@code ERROR},
  71      *                  if {@code message} is null,
  72      *                  or if {@code message} has a length of 0.
  73      */
  74     public TextOutputCallback(int messageType, String message) {
  75         if ((messageType != INFORMATION &&
  76                 messageType != WARNING && messageType != ERROR) ||
  77             message == null || message.length() == 0)
  78             throw new IllegalArgumentException();
  79 
  80         this.messageType = messageType;
  81         this.message = message;
  82     }
  83 
  84     /**
  85      * Get the message type.
  86      *
  87      * @return the message type ({@code INFORMATION},
  88      *                  {@code WARNING} or {@code ERROR}).
  89      */
  90     public int getMessageType() {
  91         return messageType;
  92     }
  93 
  94     /**
  95      * Get the message to be displayed.
  96      *
  97      * @return the message to be displayed.


  57     private String message;
  58 
  59     /**
  60      * Construct a TextOutputCallback with a message type and message
  61      * to be displayed.
  62      *
  63      * @param messageType the message type ({@code INFORMATION},
  64      *                  {@code WARNING} or {@code ERROR}).
  65      *
  66      * @param message the message to be displayed.
  67      *
  68      * @exception IllegalArgumentException if {@code messageType}
  69      *                  is not either {@code INFORMATION},
  70      *                  {@code WARNING} or {@code ERROR},
  71      *                  if {@code message} is null,
  72      *                  or if {@code message} has a length of 0.
  73      */
  74     public TextOutputCallback(int messageType, String message) {
  75         if ((messageType != INFORMATION &&
  76                 messageType != WARNING && messageType != ERROR) ||
  77             message == null || message.isEmpty())
  78             throw new IllegalArgumentException();
  79 
  80         this.messageType = messageType;
  81         this.message = message;
  82     }
  83 
  84     /**
  85      * Get the message type.
  86      *
  87      * @return the message type ({@code INFORMATION},
  88      *                  {@code WARNING} or {@code ERROR}).
  89      */
  90     public int getMessageType() {
  91         return messageType;
  92     }
  93 
  94     /**
  95      * Get the message to be displayed.
  96      *
  97      * @return the message to be displayed.
< prev index next >