コード例 #1
0
 private Described validatePublisher(Optional<String> publisher, Optional<Identified> identified) {
   Described described = (Described) identified.get();
   publisher.ifPresent(
       key -> {
         if (!key.equals(described.getPublisher().key())) {
           throw new RuntimeException(
               (String.format(
                   "Described %d is not published by '%s'", described.getId(), publisher)));
         }
       });
   return described;
 }
コード例 #2
0
  private void writeUpdate(Described described) {
    if (described instanceof Item) {
      contentWriter.createOrUpdate((Item) described);
      return;
    }

    if (described instanceof Container) {
      contentWriter.createOrUpdate((Container) described);
      return;
    }

    throw new IllegalStateException(
        (String.format("Described %d is not Item/Container", described.getId())));
  }