Shortens the loadXSection() methods by handling an empty Optional with an
IllegalStateException.

@param optional
@param message
@return
546522
private SpecialSection getOrThrow(
            Optional<? extends SpecialSection> optional, String message) {
        if (optional.isPresent()) {
            return optional.get();
        }
        throw new IllegalStateException(message);
    }
1261863
private void doQueueIsEmpty(final Message<JsonObject> message) {
    final String name = message.body().getString("name");
    if (name == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No name specified."));
      return;
    }

    context.execute(new Action<Boolean>() {
      @Override
      public Boolean perform() {
        return data.getQueue(formatKey(name)).isEmpty();
      }
    }, new Handler<AsyncResult<Boolean>>() {
      @Override
      public void handle(AsyncResult<Boolean> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          message.reply(new JsonObject().putString("status", "ok").putBoolean("result", result.result()));
        }
      }
    });
  }
100740
private void doInstalled(final Message<JsonObject> message) {
    String moduleName = message.body().getString("module");
    if (moduleName == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No module specified."));
      return;
    }

    platform.getModuleInfo(moduleName, new Handler<AsyncResult<ModuleInfo>>() {
      @Override
      public void handle(AsyncResult<ModuleInfo> result) {
        if (result.failed() || result.result() == null) {
          message.reply(new JsonObject().putString("status", "ok").putBoolean("result", false));
        } else {
          message.reply(new JsonObject().putString("status", "ok").putBoolean("result", true));
        }
      }
    });
  }
226014
public static <O extends Object> void notNull(O o, String message) {
		if(!validation) return;
		notNull(message);
		if(o == null)
			throw new ParameterException(ErrorCode.NULLPOINTER, message);
	}
359704
static JmsMessageImpl messageToJmsMessageImpl(Message message) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "messageToJmsMessageImpl", message);

        JmsMessageImpl jmsMessage = null;

        if (message instanceof BytesMessage) {
            jmsMessage = new JmsBytesMessageImpl((BytesMessage) message);
        }
        else if (message instanceof MapMessage) {
            jmsMessage = new JmsMapMessageImpl((MapMessage) message);
        }
        else if (message instanceof ObjectMessage) {
            jmsMessage = new JmsObjectMessageImpl((ObjectMessage) message);
        }
        else if (message instanceof StreamMessage) {
            jmsMessage = new JmsStreamMessageImpl((StreamMessage) message);
        }
        else if (message instanceof TextMessage) {
            jmsMessage = new JmsTextMessageImpl((TextMessage) message);
        }
        else if (message instanceof Message) {
            jmsMessage = new JmsMessageImpl(message);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "messageToJmsMessageImpl", jmsMessage);
        return jmsMessage;
    }
416772
protected String getMessageType(final String message) {
    if (StringUtils.isBlank(defaultMessageType) || MESSAGE_TYPE_TEXT_VALUE
        .equalsIgnoreCase(defaultMessageType)
        || MESSAGE_TYPE_LONG_TEXT_VALUE.equalsIgnoreCase(defaultMessageType)) {
      return message.length() > getMaxLengthOfOneSms() ? MESSAGE_TYPE_LONG_TEXT_VALUE
          : MESSAGE_TYPE_TEXT_VALUE;
    }
    return defaultMessageType;
  }
1219612
public String marshalObject(Object message)
    {
        try {
            IBindingFactory jc = BindingDirectory.getFactory(Model.class);
            IMarshallingContext marshaller = jc.createMarshallingContext();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            marshaller.setIndent(2);
            marshaller.marshalDocument(message, URL_ENCODING, null, out);
            String xml = out.toString(STRING_ENCODING);
            return xml;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (JiBXException e) {
            e.printStackTrace();
        }
        return null;
    }
720590
private String getFormAction(Message message) {
        return message.getHeader(HttpMessageHeaders.HTTP_REQUEST_URI) != null ? message.getHeader(HttpMessageHeaders.HTTP_REQUEST_URI).toString() : null;
    }
610414
private void doMapPut(final Message<JsonObject> message) {
    final String name = message.body().getString("name");
    if (name == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No name specified."));
      return;
    }

    final Object key = message.body().getValue("key");
    if (key == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No key specified."));
      return;
    }

    final Object value = message.body().getValue("value");
    if (value == null) {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No value specified."));
      return;
    }

    context.execute(new Action<Object>() {
      @Override
      public Object perform() {
        return data.getMap(formatKey(name)).put(key, value);
      }
    }, new Handler<AsyncResult<Object>>() {
      @Override
      public void handle(AsyncResult<Object> result) {
        if (result.failed()) {
          message.reply(new JsonObject().putString("status", "error").putString("message", result.cause().getMessage()));
        } else {
          message.reply(new JsonObject().putString("status", "ok").putValue("result", result.result()));
        }
      }
    });
  }
495324
@SuppressWarnings("null")
  public static
  @NonNull
  <T> T notNull(
    final @Nullable T x,
    final @NonNull String message)
  {
    if (x == null) {
      final StringBuilder text = new StringBuilder(32 + message.length());
      text.append("Expression evaluated to null: ");
      text.append(message);
      throw new NullCheckException(text.toString());
    }
    return x;
  }
1258669
@Override
    public void handleMessage(Message message) {

        handlersList = getHanderList(busType, flow);

        if (handlersList == null || handlersList.size() == 0) {

            return;
        }

        ArrayList<Handler> excutedHandlers = new ArrayList<Handler>();
        JAXRS20MessageContextImpl jaxrsMessageContext = new JAXRS20MessageContextImpl(message);
        jaxrsMessageContext.isServerSide = busType.equals(Type.SERVER);
        jaxrsMessageContext.isClientSide = busType.equals(Type.CLIENT);
        jaxrsMessageContext.setProperty(HandlerConstants.FLOW_TYPE, flow.toUpperCase());
        try {
            Iterator<Handler> it = handlersList.iterator();
            while (it.hasNext()) {
                Handler handler = it.next();
                handler.handleMessage(jaxrsMessageContext);
                excutedHandlers.add(handler);
            }
        } catch (Exception e) {
            for (int i = excutedHandlers.size() - 1; i >= 0; i--) {
                excutedHandlers.get(i).handleFault(jaxrsMessageContext);
            }
        }
    }
1372591
@SuppressWarnings("ConstantConditions")
    private void showResult(String message) {
        Snackbar.make(rootLayout, message, Snackbar.LENGTH_LONG).show();
    }
513119
@Override
	public AbstractMessage nextElement()
	{
		if (endOfQueueReached)
			throw new NoSuchElementException();
			
		try
		{
			checkNotClosed();
			AbstractMessage msg = fetchNext();
			if (msg != null)
			{
				nextMessage = null; // Consume fetched message

				// Make sure the message is fully deserialized and marked as read-only
				msg.ensureDeserializationLevel(MessageSerializationLevel.FULL);
				msg.markAsReadOnly();
				
				return msg;
			}
			
			throw new NoSuchElementException();
		}
		catch (NoSuchElementException e)
		{
			throw e;
		}
		catch (JMSException e)
		{
			throw new IllegalStateException(e.toString());
		}
	}
781412
public int sendMessage(Message message)
    {
        BaseMessageHeader messageHeader = ((BaseMessage)message).getMessageHeader();
        String strQueueType = messageHeader.getQueueType();
        String strQueueName = messageHeader.getQueueName();
        MessageSender sender = this.getMessageQueue(strQueueName, strQueueType).getMessageSender();
        if (sender != null)
            sender.sendMessage(message);
        else
            return Constant.ERROR_RETURN;  // Queue doesn't exist
        return Constant.NORMAL_RETURN;
    }
491101
public static String shortDebugString(final MessageOrBuilder message) {
    try {
      final StringBuilder sb = new StringBuilder();
      SINGLE_LINE_PRINTER.print(message, new TextGenerator(sb));
      // Single line mode currently might have an extra space at the end.
      return sb.toString().trim();
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
  }
262825
public SimpleDialog message(CharSequence message){
        if(mScrollView == null)
            initScrollView();

        if(mMessage == null)
            initMessageView();

        if(mScrollView.getChildAt(0) != mMessage) {
            mScrollView.removeAllViews();
            mScrollView.addView(mMessage);
        }

        mMessage.setText(message);
        if(!TextUtils.isEmpty(message)) {
            mMode = MODE_MESSAGE;
            super.contentView(mScrollView);
        }
        return this;
    }
895947
private void validateMessageForNull(Message msg) throws MessageFormatException {

        // if the supplied message is null, throw a jms MessageFormatException.
        if (msg == null) {
            throw (MessageFormatException) JmsErrorUtils.newThrowable(
                                                                      MessageFormatException.class,
                                                                      "INVALID_VALUE_CWSIA0068",
                                                                      new Object[] { "message", null },
                                                                      tc);
        }
    }