001/* 002 * Copyright © 2022 eXOReaction AS (rickard@exoreaction.com) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.exoreaction.xorcery.jsonapi; 017 018import com.exoreaction.xorcery.builders.With; 019import com.exoreaction.xorcery.json.JsonElement; 020import com.fasterxml.jackson.databind.node.JsonNodeFactory; 021import com.fasterxml.jackson.databind.node.ObjectNode; 022 023/** 024 * @author rickardoberg 025 */ 026public record Source(ObjectNode json) 027 implements JsonElement { 028 public record Builder(ObjectNode builder) 029 implements With<Builder> 030 { 031 public Builder() { 032 this(JsonNodeFactory.instance.objectNode()); 033 } 034 035 public Builder pointer(String value) { 036 builder.set("pointer", builder.textNode(value)); 037 return this; 038 } 039 040 public Builder parameter(String value) { 041 builder.set("detail", builder.textNode(value)); 042 return this; 043 } 044 045 public Source build() { 046 return new Source(builder); 047 } 048 } 049 050 public String getPointer() { 051 return getString("pointer").orElse(null); 052 } 053 054 public String getParameter() { 055 return getString("parameter").orElse(null); 056 } 057}