text:
package org.waveprotocol.wave.model.operation.core;

import junit.framework.TestCase;

import org.waveprotocol.wave.model.document.operation.DocOp;
import org.waveprotocol.wave.model.document.operation.impl.AttributesImpl;
import org.waveprotocol.wave.model.document.operation.impl.DocOpBuffer;
import org.waveprotocol.wave.model.id.WaveId;
import org.waveprotocol.wave.model.id.WaveletId;
import org.waveprotocol.wave.model.operation.OpComparators;
import org.waveprotocol.wave.model.operation.OperationException;
import org.waveprotocol.wave.model.util.CollectionUtils;
import org.waveprotocol.wave.model.wave.ParticipantId;
import org.waveprotocol.wave.model.wave.data.core.CoreWaveletData;
import org.waveprotocol.wave.model.wave.data.core.impl.CoreWaveletDataImpl;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * Tests for the {@code CoreWaveletOperation} containers.
 *
 * @author kalman@google.com (Benjamin Kalman)
 */

public class CoreWaveletOperationTest extends TestCase {

  private static final String DOMAIN = "example.com";
  private static final WaveId WAVE_ID = WaveId.of(DOMAIN, "hello");
  private static final WaveletId WAVELET_ID = WaveletId.of(DOMAIN, "world");
  private static final ParticipantId PARTICIPANT_ID = new ParticipantId("test@" + DOMAIN);
  private static final String DOC_ID = "doc";
  private static final String TEXT = "hi";

  private final CoreWaveletOperation addOp;
  private final CoreWaveletOperation removeOp;
  private final CoreWaveletOperation noOp;
  private final CoreWaveletOperation docOpCharacters;
  private final CoreWaveletOperation docOpDeleteCharacters;
  private final CoreWaveletOperation docOpRetainAndCharacters;
  private final CoreWaveletOperation docOpRetainAndDeleteCharacters;
  private final CoreWaveletDocumentOperation docOpComplex;

  private CoreWaveletData wavelet;
  private CoreWaveletData originalWavelet;

  public CoreWaveletOperationTest() {
    DocOpBuffer docOpBuilder;

    addOp = new CoreAddParticipant(PARTICIPANT_ID);
    removeOp = new CoreRemoveParticipant(PARTICIPANT_ID);
    noOp = CoreNoOp.INSTANCE;

    docOpBuilder = new DocOpBuffer();
    docOpBuilder.characters(TEXT);
    docOpCharacters = new CoreWaveletDocumentOperation(DOC_ID, docOpBuilder.finish());

    docOpBuilder = new DocOpBuffer();
    docOpBuilder.deleteCharacters(TEXT);
    docOpDeleteCharacters = new CoreWaveletDocumentOperation(DOC_ID, docOpBuilder.finish());

    docOpBuilder = new DocOpBuffer();
    docOpBuilder.retain(TEXT.length());
    docOpBuilder.characters(TEXT);
    docOpRetainAndCharacters = new CoreWaveletDocumentOperation(DOC_ID, docOpBuilder.finish());

    docOpBuilder = new DocOpBuffer();
    docOpBuilder.retain(TEXT.length());
    docOpBuilder.deleteCharacters(TEXT);
    docOpRetainAndDeleteCharacters = new CoreWaveletDocumentOperation(DOC_ID, docOpBuilder.finish());

    docOpBuilder = new DocOpBuffer();
    docOpBuilder.elementStart("name1",
        new AttributesImpl(CollectionUtils.immutableMap("key1", "val1", "key2", "val2")));
    docOpBuilder.characters(TEXT);
    docOpBuilder.elementStart("name2",
        new AttributesImpl(CollectionUtils.immutableMap("key3", "val3", "key4", "val4")));
    docOpBuilder.characters(TEXT + TEXT);
    docOpBuilder.elementEnd();
    docOpBuilder.characters(TEXT + TEXT + TEXT);
    docOpBuilder.elementEnd();
    docOpComplex = new CoreWaveletDocumentOperation(DOC_ID, docOpBuilder.finish());
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();
    wavelet = new CoreWaveletDataImpl(WAVE_ID, WAVELET_ID);
    originalWavelet = new CoreWaveletDataImpl(WAVE_ID, WAVELET_ID);
  }

  // Tests

  public void testTypeSanity() {
    assertTrue(noOp.getInverse() instanceof CoreNoOp);
    assertTrue(addOp.getInverse() instanceof CoreRemoveParticipant);
    assertTrue(removeOp.getInverse() instanceof CoreAddParticipant);
    assertTrue(docOpCharacters.getInverse() instanceof CoreWaveletDocumentOperation);
    assertTrue(docOpDeleteCharacters.getInverse() instanceof CoreWaveletDocumentOperation);
    assertTrue(docOpRetainAndCharacters.getInverse() instanceof CoreWaveletDocumentOperation);
    assertTrue(docOpRetainAndDeleteCharacters.getInverse() instanceof CoreWaveletDocumentOperation);
  }

  public void testConcreteInverse() {
    assertEquals(addOp.getInverse(), removeOp);
    assertEquals(removeOp.getInverse(), addOp);
    assertEquals(docOpCharacters.getInverse(), docOpDeleteCharacters);
    assertEquals(docOpDeleteCharacters.getInverse(), docOpCharacters);
    assertEquals(docOpRetainAndCharacters.getInverse(), docOpRetainAndDeleteCharacters);
    assertEquals(docOpRetainAndDeleteCharacters.getInverse(), docOpRetainAndCharacters);
  }

  public void testAddParticipant() throws OperationException {
    assertOpInvertible(addOp);
    addOp.apply(wavelet);
    assertListEquals(wavelet.getParticipants(), CollectionUtils.newArrayList(PARTICIPANT_ID));
  }

  public void testRemoveParticipant() throws OperationException {
    wavelet.addParticipant(PARTICIPANT_ID);
    originalWavelet.addParticipant(PARTICIPANT_ID);
    assertOpInvertible(removeOp);
  }

  public void testNoOp() throws OperationException {
    assertOpInvertible(noOp);
  }

  public void testCharacters() throws OperationException {
    assertOpInvertible(docOpCharacters);
  }

  public void testDeleteCharacters() throws OperationException {
    assertOpsInvertible(CollectionUtils.newArrayList(docOpCharacters, docOpDeleteCharacters));
    docOpCharacters.apply(wavelet);
    docOpCharacters.apply(originalWavelet);
    assertOpInvertible(docOpDeleteCharacters);
  }

  public void testRetainAndCharacters() throws OperationException {
    assertOpsInvertible(CollectionUtils.newArrayList(docOpCharacters, docOpRetainAndCharacters));
  }

  public void testRetainAndDeleteCharacters() throws OperationException {
    assertOpsInvertible(CollectionUtils.newArrayList(
        docOpCharacters, docOpRetainAndCharacters, docOpRetainAndDeleteCharacters));
    docOpCharacters.apply(wavelet);
    docOpCharacters.apply(originalWavelet);
    assertOpsInvertible(CollectionUtils.newArrayList(
        docOpRetainAndCharacters, docOpRetainAndDeleteCharacters));
  }

  public void testComplex() throws OperationException {
    assertOpInvertible(docOpComplex);
  }

  // Help

  private void assertOpInvertible(CoreWaveletOperation op) throws OperationException {
    assertOpsInvertible(CollectionUtils.newArrayList(op));
  }

  private void assertOpsInvertible(List<CoreWaveletOperation> ops) throws OperationException {
    assertOpListEquals(ops, getInverse(getInverse(ops)));
    for (CoreWaveletOperation op : ops) {
      op.apply(wavelet);
    }
    for (CoreWaveletOperation op : getInverse(ops)) {
      op.apply(wavelet);
    }
    assertWaveletEquals(wavelet, originalWavelet);
  }

  private List<CoreWaveletOperation> getInverse(List<CoreWaveletOperation> ops) {
    List<CoreWaveletOperation> inverse = CollectionUtils.newArrayList();
    for (CoreWaveletOperation op : ops) {
      inverse.add(op.getInverse());
    }
    Collections.reverse(inverse);
    return inverse;
  }

  private void assertWaveletEquals(CoreWaveletData w1, CoreWaveletData w2) {
    assertEquals(w1.getWaveletName(), w2.getWaveletName());
    assertListEquals(w1.getParticipants(), w2.getParticipants());

    Map<String, DocOp> docs1 = w1.getDocuments();
    Map<String, DocOp> docs2 = w2.getDocuments();

    List<String> docKeys1 = CollectionUtils.newArrayList(docs1.keySet());
    Collections.sort(docKeys1);
    List<String> docKeys2 = CollectionUtils.newArrayList(docs2.keySet());
    Collections.sort(docKeys2);
    assertListEquals(docKeys1, docKeys2);

    for (String key : docKeys1) {
      assertOpEquals(docs1.get(key), docs2.get(key));
    }
  }

  private void assertOpListEquals(List<CoreWaveletOperation> l1, List<CoreWaveletOperation> l2) {
    assertEquals(l1.size(), l2.size());
    for (int i = 0; i < l1.size(); i++) {
      assertEquals(l1.get(i), l2.get(i));
    }
  }

  private void assertOpEquals(DocOp op1, DocOp op2) {
    assertTrue(OpComparators.SYNTACTIC_IDENTITY.equal(op1, op2));
  }

  private void assertListEquals(List<?> l1, List<?> l2) {
    assertEquals(l1.size(), l2.size());
    for (int i = 0; i < l1.size(); i++) {
      assertEquals(l1.get(i), l2.get(i));
    }
  }
}


text:
@implementation CHTopicBasicView

- (void)awakeFromNib{
    [super awakeFromNib];
    self.autoresizingMask = NO;
}
+ (instancetype)loadXib{
    //NSLog(@"loadxib%@",self);
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}
- (void)setAllItem:(CHAllItem *)allItem{
    _allItem = allItem;

}
@end

redpajama_set_name: RedPajamaGithub


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;
using Xunit;

namespace System.ServiceModel.Syndication.Tests
{
    public class SyndicationElementExtensionCollectionTests
    {
        [Fact]
        public void Add_Invoke_ReturnsExpected()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 10 });
            elementExtensions.Add(new SyndicationElementExtension(new ExtensionObject { Value = 11 }));
            using (var stringReader = new StringReader(@"<SyndicationElementExtensionCollectionTests.ExtensionObject xmlns=""http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Value>12</Value></SyndicationElementExtensionCollectionTests.ExtensionObject>"))
            using (XmlReader reader = XmlReader.Create(stringReader))
            {
                elementExtensions.Add(reader);
            }
            elementExtensions.Add(new ExtensionObject { Value = 13 }, new DataContractSerializer(typeof(ExtensionObject)));
            elementExtensions.Add(new ExtensionObject { Value = 14 }, (DataContractSerializer)null);
            elementExtensions.Add(new ExtensionObject { Value = 15 }, new XmlSerializer(typeof(ExtensionObject)));
            elementExtensions.Add(new ExtensionObject { Value = 16 }, (XmlSerializer)null);
            elementExtensions.Add("outerName", "outerNamespace", new ExtensionObject { Value = 17 });
            elementExtensions.Add("outerName", "outerNamespace", new ExtensionObject { Value = 18 }, new DataContractSerializer(typeof(ExtensionObject)));
            elementExtensions.Add("outerName", "outerNamespace", new ExtensionObject { Value = 19 }, null);

            Assert.Equal(10, elementExtensions.Count);

            using (XmlReader reader = elementExtensions.GetReaderAtElementExtensions())
            {
                Assert.Equal(@"<SyndicationElementExtensionCollectionTests.ExtensionObject xmlns=""http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><Value>10</Value></SyndicationElementExtensionCollectionTests.ExtensionObject>", reader.ReadOuterXml());
            }
        }

        [Fact]
        public void Add_NullDataContractExtension_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentNullException>("dataContractExtension", () => elementExtensions.Add((object)null));
            AssertExtensions.Throws<ArgumentNullException>("dataContractExtension", () => elementExtensions.Add(null, new DataContractSerializer(typeof(ExtensionObject))));
            AssertExtensions.Throws<ArgumentNullException>("dataContractExtension", () => elementExtensions.Add("outerName", "outerNamespace", null));
            AssertExtensions.Throws<ArgumentNullException>("dataContractExtension", () => elementExtensions.Add("outerName", "outerNamespace", null, new DataContractSerializer(typeof(ExtensionObject))));
        }

        [Fact]
        public void Add_NullXmlSerializerExtension_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentNullException>("xmlSerializerExtension", () => elementExtensions.Add(null, new XmlSerializer(typeof(ExtensionObject))));
        }

        [Fact]
        public void Add_NullReader_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentNullException>("xmlReader", () => elementExtensions.Add(null));
        }

        [Fact]
        public void Clear_Invoke_Success()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 10 });

            elementExtensions.Clear();
            Assert.Equal(0, elementExtensions.Count);

            elementExtensions.Clear();
            Assert.Equal(0, elementExtensions.Count);
        }

        [Fact]
        public void Insert_Invoke_Success()
        {
            var extension = new SyndicationElementExtension(new ExtensionObject { Value = 10 });
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;

            elementExtensions.Insert(0, extension);
            Assert.Same(extension, elementExtensions[0]);
        }

        [Fact]
        public void Insert_Null_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentNullException>("item", () => elementExtensions.Insert(0, null));
        }

        [Fact]
        public void ItemSet_Get_ReturnsExpected()
        {
            var extension = new SyndicationElementExtension(new ExtensionObject { Value = 10 });
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 9 });

            elementExtensions[0] = extension;
            Assert.Same(extension, elementExtensions[0]);
        }

        [Fact]
        public void ItemSet_Null_ThrowsArgumentNullException()
        {
            var extension = new SyndicationElementExtension(new ExtensionObject { Value = 10 });
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 9 });

            AssertExtensions.Throws<ArgumentNullException>("item", () => elementExtensions[0] = null);
        }

        [Fact]
        public void Remove_Invoke_Success()
        {
            var extension = new SyndicationElementExtension(new ExtensionObject { Value = 10 });
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(extension);

            elementExtensions.RemoveAt(0);
            Assert.Equal(0, elementExtensions.Count);
        }

        [Fact]
        public void GetReaderAtElementExtensions_InvokeMultipleTimes_ReturnsNewReader()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            Assert.NotSame(elementExtensions.GetReaderAtElementExtensions(), elementExtensions.GetReaderAtElementExtensions());
        }

        [Fact]
        public void ReadElementExtensions_Invoke_ReturnsExpected()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 10 });
            elementExtensions.Add(new ExtensionObject { Value = 11 });
            elementExtensions.Add(new OtherExtensionObject { Value = 11 });
            elementExtensions.Add(new Inner.OtherExtensionObject { Value = 11 });

            Collection<ExtensionObject> results = elementExtensions.ReadElementExtensions<ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests");
            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);

            results = elementExtensions.ReadElementExtensions<ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests", new DataContractSerializer(typeof(ExtensionObject)));
            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);

            results = elementExtensions.ReadElementExtensions<ExtensionObject>("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests", new XmlSerializer(typeof(ExtensionObject)));
            Assert.Equal(2, results.Count);
            Assert.Equal(10, results[0].Value);
            Assert.Equal(11, results[1].Value);
        }

        [Theory]
        [InlineData("NoSuchObject", null)]
        [InlineData("SyndicationElementExtensionCollectionTests.ExtensionObject", "")]
        [InlineData("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Testss")]
        [InlineData("SyndicationElementExtensionCollectionTests.extensionobject", "http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication.Tests")]
        [InlineData("SyndicationElementExtensionCollectionTests.ExtensionObject", "http://schemas.datacontract.org/2004/07/system.servicemodel.syndication.tests")]
        [InlineData("SyndicationElementExtensionCollectionTests.ExtensionObject", "System.ServiceModel.Syndication.Tests")]
        public void ReadElementExtensions_NoSuchObject_ReturnsEmpty(string name, string ns)
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 10 });
            elementExtensions.Add(new ExtensionObject { Value = 11 });

            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>(name, ns));
            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>(name, ns, new DataContractSerializer(typeof(ExtensionObject))));
            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>(name, ns, new XmlSerializer(typeof(ExtensionObject))));
        }

        [Fact]
        public void ReadElementExtensions_Empty_ReturnsEmpty()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>("ExtensionName", null));
            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>("ExtensionName", null, new DataContractSerializer(typeof(ExtensionObject))));
            Assert.Empty(elementExtensions.ReadElementExtensions<ExtensionObject>("ExtensionName", null, new XmlSerializer(typeof(ExtensionObject))));
        }

        [Fact]
        public void ReadElementExtensions_NullSerializer_ThrowsArgumentNullException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentNullException>("serializer", () => elementExtensions.ReadElementExtensions<SyndicationElementExtension>("extensionName", "extensionNamespace", (XmlObjectSerializer)null));
            AssertExtensions.Throws<ArgumentNullException>("serializer", () => elementExtensions.ReadElementExtensions<SyndicationElementExtension>("extensionName", "extensionNamespace", (XmlSerializer)null));
        }

        [Fact]
        public void ReadElementExtensions_EmptyExtensionName_ThrowsArgumentException()
        {
            SyndicationElementExtensionCollection elementExtensions = new SyndicationCategory().ElementExtensions;
            AssertExtensions.Throws<ArgumentException>(null, () => elementExtensions.ReadElementExtensions<SyndicationElementExtension>("", "extensionNamespace"));
            AssertExtensions.Throws<ArgumentException>(null, () => elementExtensions.ReadElementExtensions<SyndicationElementExtension>("", "extensionNamespace", new DataContractSerializer(typeof(ExtensionObject))));
            AssertExtensions.Throws<ArgumentException>(null, () => elementExtensions.ReadElementExtensions<SyndicationElementExtension>("", "extensionNamespace", new XmlSerializer(typeof(ExtensionObject))));
        }

        [Fact]
        public void Clone_NoExtensions_ReturnsExpected()
        {
            var category = new SyndicationCategory();
            SyndicationElementExtensionCollection elementExtensions = category.ElementExtensions;

            SyndicationElementExtensionCollection clone = category.Clone().ElementExtensions;
            Assert.Empty(clone);
        }

        [Fact]
        public void Clone_WithExtensions_ReturnsExpected()
        {
            var category = new SyndicationCategory();

            SyndicationElementExtensionCollection elementExtensions = category.ElementExtensions;
            elementExtensions.Add(new ExtensionObject { Value = 10 });

            SyndicationElementExtensionCollection clone = category.Clone().ElementExtensions;
            Assert.Equal(1, clone.Count);

            elementExtensions.Clear();
            Assert.Equal(1, clone.Count);
        }

        [DataContract]
        public class ExtensionObject
        {
            [DataMember]
            public int Value { get; set; }
        }

        [DataContract]
        public class OtherExtensionObject
        {
            [DataMember]
            public int Value { get; set; }
        }
    }
}

namespace System.ServiceModel.Syndication.Tests.Inner
{
    [DataContract]
    public class OtherExtensionObject
    {
        [DataMember]
        public int Value { get; set; }
    }
}


text:
@interface XYFriendTrednsViewController ()

@end

@implementation XYFriendTrednsViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationItem.title = @"关注";
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:[UIImage imageNamed:@"friendsRecommentIcon"] highlightImage:[UIImage imageNamed:@"friendsRecommentIcon-click"] target:self action:@selector(recommendClick)];
}

- (IBAction)loginOrRegister
{
    XYLoginRegisterViewController *loginRegisterViewController = [[XYLoginRegisterViewController alloc] init];

    [self presentViewController:loginRegisterViewController animated:YES completion:nil];
}

- (void)recommendClick
{
    XYRecommendViewController *recommendVc = [[XYRecommendViewController alloc] init];
    recommendVc.navigationItem.title = @"推荐关注";
    [self.navigationController pushViewController:recommendVc animated:YES];
}

@end


text:
package org.apache.flink.table.planner.utils;

import org.apache.flink.table.api.Schema;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;

import org.hamcrest.Description;
import org.hamcrest.FeatureMatcher;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeDiagnosingMatcher;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.hamcrest.CoreMatchers.equalTo;

/** {@link Matcher Matchers} for asserting {@link Operation}. */
public class OperationMatchers {
    /**
     * Checks for a {@link CreateTableOperation}. You can provide additional matchers as parameters.
     * All of the provided nested matchers must match.
     *
     *
Example:
     *
     *
{@code
     * assertThat(
     * 	operation,
     * 	createTableOperation(
     * 		hasSchema(
     * 			TableSchema.builder()
     * 				.field("f0", DataTypes.INT().notNull())
     * 				.field("f1", DataTypes.TIMESTAMP(3))
     * 				.field("a", DataTypes.INT())
     * 				.watermark("f1", "`f1` - INTERVAL '5' SECOND", DataTypes.TIMESTAMP(3))
     * 				.build()
     * 		),
     * 		hasOptions(
     * 			entry("connector.type", "kafka"),
     * 			entry("format.type", "json")
     * 		),
     * 		hasPartition(
     * 			"a", "f0"
     * 		)
     * 	)
     * );
     * }

     *
     * @param nestedMatchers additional matchers that must match
     * @see #withOptions(MapEntry[])
     * @see #withSchema(Schema)
     * @see #partitionedBy(String...)
     */
    @SafeVarargs
    public static Matcher<Operation> isCreateTableOperation(
            Matcher<CreateTableOperation>... nestedMatchers) {
        return new CreateTableOperationMatcher(nestedMatchers);
    }

    /**
     * Checks that the {@link CreateTableOperation} has all given connector options.
     *
     * @param entries Connector options to check.
     * @see #entry(String, String)
     */
    @SafeVarargs
    public static Matcher<CreateTableOperation> withOptions(MapEntry<String, String>... entries) {
        return new FeatureMatcher<CreateTableOperation, Map<String, String>>(
                equalTo(mapOf(entries)), "options of the derived table", "options") {
            @Override
            protected Map<String, String> featureValueOf(CreateTableOperation actual) {
                return actual.getCatalogTable().getOptions();
            }
        };
    }

    /** Helper method for easier creating maps in matchers. */
    public static MapEntry<String, String> entry(String key, String value) {
        return new MapEntry<>(key, value);
    }

    /**
     * Checks that the {@link CreateTableOperation} is partitioned by given fields.
     *
     * @param fields Fields on which the Table should be partitioned.
     * @see #isCreateTableOperation(Matcher[])
     */
    public static Matcher<CreateTableOperation> partitionedBy(String... fields) {
        return new FeatureMatcher<CreateTableOperation, List<String>>(
                equalTo(Arrays.asList(fields)), "partitions of the derived table", "partitions") {
            @Override
            protected List<String> featureValueOf(CreateTableOperation actual) {
                return actual.getCatalogTable().getPartitionKeys();
            }
        };
    }

    /**
     * Checks that the schema of {@link CreateTableOperation} is equal to the given {@link Schema}.
     *
     * @param schema TableSchema that the {@link CreateTableOperation} should have
     * @see #isCreateTableOperation(Matcher[])
     */
    public static Matcher<CreateTableOperation> withSchema(Schema schema) {
        return new FeatureMatcher<CreateTableOperation, Schema>(
                equalTo(schema), "schema of the derived table", "schema") {
            @Override
            protected Schema featureValueOf(CreateTableOperation actual) {
                return actual.getCatalogTable().getUnresolvedSchema();
            }
        };
    }

    /** Helper class for easier creating maps in matchers. */
    public static class MapEntry<K, V> {
        private final K key;
        private final V value;

        public MapEntry(K key, V value) {
            this.key = key;
            this.value = value;
        }
    }

    @SafeVarargs
    private static Map<String, String> mapOf(MapEntry<String, String>... entries) {
        Map<String, String> map = new HashMap<>();
        for (MapEntry<String, String> entry : entries) {
            map.put(entry.key, entry.value);
        }

        return map;
    }

    private static class CreateTableOperationMatcher extends TypeSafeDiagnosingMatcher<Operation> {
        private final Matcher<CreateTableOperation>[] nestedMatchers;

        public CreateTableOperationMatcher(Matcher<CreateTableOperation>[] nestedMatchers) {
            this.nestedMatchers = nestedMatchers;
        }

        @Override
        protected boolean matchesSafely(Operation item, Description mismatchDescription) {
            if (!(item instanceof CreateTableOperation)) {

                return false;
            }

            for (Matcher<CreateTableOperation> nestedMatcher : nestedMatchers) {
                if (!nestedMatcher.matches(item)) {
                    nestedMatcher.describeMismatch(item, mismatchDescription);
                    return false;
                }
            }

            return true;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("\n");
            Arrays.stream(nestedMatchers)
                    .forEach(
                            matcher -> {
                                matcher.describeTo(description);
                                description.appendText("\n");
                            });
        }
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Startable</title>
<meta name="date" content="2014-12-16">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

weka.gui.beans

Interface Startable

All Known Implementing Classes:

Loader

public interface Startable

Interface to something that is a start point for a flow and
 can be launched programatically.

Since:

1.0

Version:

$Revision: 6017 $

Author:

Mark Hall (mhall{[at]}pentaho{[dot]}org)

Method Summary

Methods

Modifier and Type
Method and Description

java.lang.String
getStartMessage()

Gets a string that describes the start action.

void
start()

Start the flow running

Method Detail

start

void start()
           throws java.lang.Exception

Start the flow running

Throws:

java.lang.Exception - if something goes wrong

getStartMessage

java.lang.String getStartMessage()

Gets a string that describes the start action. The
 KnowledgeFlow uses this in the popup contextual menu
 for the component. The string can be proceeded by
 a '$' character to indicate that the component can't
 be started at present.

Returns:

a string describing the start action.

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method


text:
package testing

import (
	"testing"

	"k8s.io/component-base/config/v1alpha1"
	"k8s.io/kube-scheduler/config/v1beta2"
	"k8s.io/kubernetes/pkg/scheduler/apis/config"
	"k8s.io/kubernetes/pkg/scheduler/apis/config/scheme"
)

// V1beta2ToInternalWithDefaults creates a v1beta2 default configuration.
func V1beta2ToInternalWithDefaults(t *testing.T, versionedCfg v1beta2.KubeSchedulerConfiguration) *config.KubeSchedulerConfiguration {
	versionedCfg.DebuggingConfiguration = *v1alpha1.NewRecommendedDebuggingConfiguration()

	scheme.Scheme.Default(&versionedCfg)
	cfg := config.KubeSchedulerConfiguration{}
	if err := scheme.Scheme.Convert(&versionedCfg, &cfg, nil); err != nil {
		t.Fatal(err)
	}
	return &cfg
}


text:
package timedconnections;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.InterruptedException;
import java.lang.Runnable;
import java.net.Socket;

class Worker implements Runnable
{
    private int sleepTime = 10;

    /**
     * Socket connection (oh really?)
     */
    private Socket connection;
    /**
     * Function to call after the socket connection is closed.
     */
    private Disposer disposer;

    /**
     * Create a socket handler.
     *
     * @param connection The socket connection to handle.
     * @param disposer Function to call when the socket connection closes.
     */
    public Worker(Socket connection, Disposer disposer) {
        this.connection = connection;
        this.disposer = disposer;
    }

    /**
     * Handle a connection, i.e. wait for 10 seconds and close.
     */
    public void run() {
        try {
            PrintWriter pout = new PrintWriter(connection.getOutputStream(), true);

            while (sleepTime > 0) {
                String s = (sleepTime == 1) ? " second." : " seconds.";
                pout.println("Sleeping " + sleepTime + " more " + s);
                Thread.sleep(1000);
                sleepTime -= 1;
            }

            // now close the socket connection
            connection.close();
        }
        catch (InterruptedException e) {
            System.err.println("Interrupted: " + e.getMessage());
        }
        catch (IOException e) {
            System.err.println("IOException: " + e.getMessage());
        }
        finally {
            this.disposer.dispose();
        }
    }
}


text:
/*	$OpenBSD: specialreg.h,v 1.7 1999/03/08 23:47:25 downsj Exp $	*/
/*	$NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $	*/

/*-
 * Copyright (c) 1991 The Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)specialreg.h	7.1 (Berkeley) 5/9/91
 */

/*
 * Bits in 386 special registers:
 */
#define	CR0_PE	0x00000001	/* Protected mode Enable */
#define	CR0_MP	0x00000002	/* "Math" Present (NPX or NPX emulator) */
#define	CR0_EM	0x00000004	/* EMulate non-NPX coproc. (trap ESC only) */
#define	CR0_TS	0x00000008	/* Task Switched (if MP, trap ESC and WAIT) */
#define	CR0_ET	0x00000010	/* Extension Type (387 (if set) vs 287) */
#define	CR0_PG	0x80000000	/* PaGing enable */

/*
 * Bits in 486 special registers:
 */
#define CR0_NE	0x00000020	/* Numeric Error enable (EX16 vs IRQ13) */
#define CR0_WP	0x00010000	/* Write Protect (honor PG_RW in all modes) */
#define CR0_AM	0x00040000	/* Alignment Mask (set to enable AC flag) */
#define	CR0_NW	0x20000000	/* Not Write-through */
#define	CR0_CD	0x40000000	/* Cache Disable */

/*
 * Cyrix 486 DLC special registers, accessable as IO ports.
 */
#define CCR0	0xc0		/* configuration control register 0 */
#define CCR0_NC0	0x01	/* first 64K of each 1M memory region is non-cacheable */
#define CCR0_NC1	0x02	/* 640K-1M region is non-cacheable */
#define CCR0_A20M	0x04	/* enables A20M# input pin */
#define CCR0_KEN	0x08	/* enables KEN# input pin */
#define CCR0_FLUSH	0x10	/* enables FLUSH# input pin */
#define CCR0_BARB	0x20	/* flushes internal cache when entering hold state */
#define CCR0_CO		0x40	/* cache org: 1=direct mapped, 0=2x set assoc */
#define CCR0_SUSPEND	0x80	/* enables SUSP# and SUSPA# pins */

#define CCR1	0xc1		/* configuration control register 1 */
#define CCR1_RPL	0x01	/* enables RPLSET and RPLVAL# pins */
/* the remaining 7 bits of this register are reserved */

/*
 * bits in the pentiums %cr4 register:
 */

#define CR4_VME	0x00000001	/* virtual 8086 mode extension enable */
#define CR4_PVI 0x00000002	/* protected mode virtual interrupt enable */
#define CR4_TSD 0x00000004	/* restrict RDTSC instruction to cpl 0 only */
#define CR4_DE	0x00000008	/* debugging extension */
#define CR4_PSE	0x00000010	/* large (4MB) page size enable */
#define CR4_PAE 0x00000020	/* physical address extension enable */
#define CR4_MCE	0x00000040	/* machine check enable */
#define CR4_PGE	0x00000080	/* page global enable */
#define CR4_PCE	0x00000100	/* enable RDPMC instruction for all cpls */

/*
 * CPUID "features" (and "extended features") bits:
 */

#define CPUID_FPU	0x00000001	/* processor has an FPU? */
#define CPUID_VME	0x00000002	/* has virtual mode (%cr4's VME/PVI) */
#define CPUID_DE	0x00000004	/* has debugging extension */
#define CPUID_PSE	0x00000008	/* has 4MB page size extension */
#define CPUID_TSC	0x00000010	/* has time stamp counter */
#define CPUID_MSR	0x00000020	/* has mode specific registers */
#define CPUID_PAE	0x00000040	/* has phys address extension */
#define CPUID_MCE	0x00000080	/* has machine check exception */
#define CPUID_CX8	0x00000100	/* has CMPXCHG8B instruction */
#define CPUID_APIC	0x00000200	/* has enabled APIC */
#define CPUID_SYS1	0x00000400	/* has SYSCALL/SYSRET inst. (Cyrix) */
#define CPUID_SYS2	0x00000800	/* has SYSCALL/SYSRET inst. (AMD/Intel) */
#define CPUID_MTRR	0x00001000	/* has memory type range register */
#define CPUID_PGE	0x00002000	/* has page global extension */
#define CPUID_MCA	0x00004000	/* has machine check architecture */
#define CPUID_CMOV	0x00008000	/* has CMOVcc instruction */
#define CPUID_PAT	0x00010000	/* has page attribute table */
#define CPUID_PSE36	0x00020000	/* has 36bit page size extension */
#define CPUID_SER	0x00040000	/* has processor serial number */
#define CPUID_MMX	0x00800000	/* has MMX instructions */
#define CPUID_FXSR	0x01000000	/* has FXRSTOR instruction (Intel) */
#define CPUID_EMMX	0x01000000	/* has extended MMX (Cyrix; obsolete) */
#define CPUID_SIMD	0x02000000	/* has SIMD instructions (Intel) */
#define CPUID_3DNOW	0x80000000	/* has 3DNow! instructions (AMD) */

/*
 * the following four 3-byte registers control the non-cacheable regions.
 * These registers must be written as three seperate bytes.
 *
 * NCRx+0: A31-A24 of starting address
 * NCRx+1: A23-A16 of starting address
 * NCRx+2: A15-A12 of starting address | NCR_SIZE_xx.
 *
 * The non-cacheable region's starting address must be aligned to the
 * size indicated by the NCR_SIZE_xx field.
 */
#define NCR1	0xc4
#define NCR2	0xc7
#define NCR3	0xca
#define NCR4	0xcd

#define NCR_SIZE_0K	0
#define NCR_SIZE_4K	1
#define NCR_SIZE_8K	2
#define NCR_SIZE_16K	3
#define NCR_SIZE_32K	4
#define NCR_SIZE_64K	5
#define NCR_SIZE_128K	6
#define NCR_SIZE_256K	7
#define NCR_SIZE_512K	8
#define NCR_SIZE_1M	9
#define NCR_SIZE_2M	10
#define NCR_SIZE_4M	11
#define NCR_SIZE_8M	12
#define NCR_SIZE_16M	13
#define NCR_SIZE_32M	14
#define NCR_SIZE_4G	15


text:
#include "mutex_and_signal.h"
#include <pthread.h>
#include <assert.h>
#include "safe_memory_operations.h"
#include "err.h"

struct MutexAndSignal {
  pthread_mutex_t lock;
  pthread_cond_t signal;
};

MutexAndSignal_pointer MutexAndSignal_create() {
  MutexAndSignal_pointer this = new(struct MutexAndSignal);
  if (pthread_mutex_init(&this->lock, 0) != 0)
    syserr("MutexAndSignal_create: gMutex init failed");
  if (pthread_cond_init(&this->signal, 0) != 0)
    syserr("MutexAndSignal_create: signal init failed");
  return this;
}

void MutexAndSignal_lock(MutexAndSignal_pointer this) {
  assert(this != NULL);
  if (pthread_mutex_lock(&this->lock) != 0)
    syserr("MutexAndSignal_lock lock failed");
}

void MutexAndSignal_unlock(MutexAndSignal_pointer this) {
  assert(this != NULL);
  if (pthread_mutex_unlock(&this->lock) != 0)
    syserr("MutexAndSignal_unlock unlock failed");
}

void MutexAndSignal_wait(MutexAndSignal_pointer this) {
  assert(this != NULL);
  if (pthread_cond_wait(&this->signal, &this->lock) != 0)
    syserr("MutexAndSignal_wait cond wait failed");
}

void MutexAndSignal_signal(MutexAndSignal_pointer this) {
  if (pthread_cond_signal(&this->signal) != 0)
    syserr("MutexAndSignal_signal cond signal failed");
}

void MutexAndSignal_destroy(MutexAndSignal_pointer this) {
  assert(this != NULL);
  if (pthread_cond_destroy(&this->signal) != 0)
    syserr("MutexAndSignal_destroy cond destroy failed");
  if (pthread_mutex_destroy(&this->lock) != 0)
    syserr("MutexAndSignal_destroy gMutex destroy failed");

  free(this);
}


text:
/**
 * Generated by API Builder - https://www.apibuilder.io
 * Service version: 0.15.80
 * apibuilder 0.15.33 app.apibuilder.io/apicollective/apibuilder-api-json/latest/play_2_x_json
 */
package io.apibuilder.api.json.v0.models {

  final case class Annotation(
    description: _root_.scala.Option[String] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class ApiJson(
    name: String,
    info: _root_.scala.Option[io.apibuilder.api.json.v0.models.Info] = None,
    namespace: _root_.scala.Option[String] = None,
    baseUrl: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    imports: Seq[io.apibuilder.api.json.v0.models.Import] = Nil,
    headers: Seq[io.apibuilder.api.json.v0.models.Header] = Nil,
    enums: Map[String, io.apibuilder.api.json.v0.models.Enum] = Map.empty,
    interfaces: Map[String, io.apibuilder.api.json.v0.models.Interface] = Map.empty,
    templates: _root_.scala.Option[io.apibuilder.api.json.v0.models.Templates] = None,
    unions: Map[String, io.apibuilder.api.json.v0.models.Union] = Map.empty,
    models: Map[String, io.apibuilder.api.json.v0.models.Model] = Map.empty,
    resources: Map[String, io.apibuilder.api.json.v0.models.Resource] = Map.empty,
    annotations: Map[String, io.apibuilder.api.json.v0.models.Annotation] = Map.empty,
    attributes: Seq[io.apibuilder.api.json.v0.models.Attribute] = Nil
  )

  final case class Attribute(
    name: String,
    value: _root_.play.api.libs.json.JsObject
  )

  final case class Body(
    `type`: String,
    description: _root_.scala.Option[String] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Contact(
    name: _root_.scala.Option[String] = None,
    url: _root_.scala.Option[String] = None,
    email: _root_.scala.Option[String] = None
  )

  final case class Deprecation(
    description: _root_.scala.Option[String] = None
  )

  final case class Enum(
    plural: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    values: Seq[io.apibuilder.api.json.v0.models.EnumValue],
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class EnumValue(
    name: String,
    value: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Field(
    name: String,
    `type`: String,
    description: _root_.scala.Option[String] = None,
    required: Boolean = true,
    default: _root_.scala.Option[_root_.play.api.libs.json.JsValue] = None,
    example: _root_.scala.Option[String] = None,
    minimum: _root_.scala.Option[Long] = None,
    maximum: _root_.scala.Option[Long] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    annotations: _root_.scala.Option[Seq[String]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Header(
    name: String,
    `type`: String,
    required: Boolean = true,
    description: _root_.scala.Option[String] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Import(
    uri: String
  )

  final case class Info(
    contact: _root_.scala.Option[io.apibuilder.api.json.v0.models.Contact] = None,
    license: _root_.scala.Option[io.apibuilder.api.json.v0.models.License] = None
  )

  final case class Interface(
    plural: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    fields: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Field]] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  /**
   * Describes the software license contact for this service
   */

  final case class License(
    name: String,
    url: _root_.scala.Option[String] = None
  )

  final case class Model(
    description: _root_.scala.Option[String] = None,
    plural: _root_.scala.Option[String] = None,
    fields: Seq[io.apibuilder.api.json.v0.models.Field] = Nil,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    interfaces: _root_.scala.Option[Seq[String]] = None,
    templates: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.TemplateDeclaration]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Operation(
    method: String,
    path: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    body: _root_.scala.Option[io.apibuilder.api.json.v0.models.Body] = None,
    parameters: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Parameter]] = None,
    responses: _root_.scala.Option[Map[String, io.apibuilder.api.json.v0.models.Response]] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Parameter(
    name: String,
    `type`: String,
    location: io.apibuilder.api.json.v0.models.ParameterLocation = io.apibuilder.api.json.v0.models.ParameterLocation.Query,
    description: _root_.scala.Option[String] = None,
    required: Boolean = true,
    default: _root_.scala.Option[_root_.play.api.libs.json.JsValue] = None,
    minimum: _root_.scala.Option[Long] = None,
    maximum: _root_.scala.Option[Long] = None,
    example: _root_.scala.Option[String] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Resource(
    path: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    operations: Seq[io.apibuilder.api.json.v0.models.Operation] = Nil,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    templates: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.TemplateDeclaration]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class Response(
    `type`: String,
    headers: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Header]] = None,
    description: _root_.scala.Option[String] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None
  )

  /**
   * @param cast Casts the types declared in the template to the types you want to use in this
   *        declaration
   */

  final case class TemplateDeclaration(
    name: String,
    cast: _root_.scala.Option[Map[String, String]] = None
  )

  /**
   * Experimental
   */

  final case class Templates(
    models: _root_.scala.Option[Map[String, io.apibuilder.api.json.v0.models.Model]] = None,
    resources: _root_.scala.Option[Map[String, io.apibuilder.api.json.v0.models.Resource]] = None
  )

  final case class Union(
    plural: _root_.scala.Option[String] = None,
    discriminator: _root_.scala.Option[String] = None,
    description: _root_.scala.Option[String] = None,
    types: Seq[io.apibuilder.api.json.v0.models.UnionType],
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    interfaces: _root_.scala.Option[Seq[String]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )

  final case class UnionType(
    `type`: String,
    description: _root_.scala.Option[String] = None,
    default: Boolean = false,
    discriminatorValue: _root_.scala.Option[String] = None,
    attributes: _root_.scala.Option[Seq[io.apibuilder.api.json.v0.models.Attribute]] = None,
    deprecation: _root_.scala.Option[io.apibuilder.api.json.v0.models.Deprecation] = None
  )
  sealed trait ParameterLocation extends _root_.scala.Product with _root_.scala.Serializable

  object ParameterLocation {

    case object Path extends ParameterLocation { override def toString = "path" }
    case object Query extends ParameterLocation { override def toString = "query" }
    case object Form extends ParameterLocation { override def toString = "form" }
    case object Header extends ParameterLocation { override def toString = "header" }
    /**
     * UNDEFINED captures values that are sent either in error or
     * that were added by the server after this library was
     * generated. We want to make it easy and obvious for users of
     * this library to handle this case gracefully.
     *
     * We use all CAPS for the variable name to avoid collisions
     * with the camel cased values above.
     */
    final case class UNDEFINED(override val toString: String) extends ParameterLocation

    /**
     * all returns a list of all the valid, known values. We use
     * lower case to avoid collisions with the camel cased values
     * above.
     */
    val all: scala.List[ParameterLocation] = scala.List(Path, Query, Form, Header)

    private[this]
    val byName: Map[String, ParameterLocation] = all.map(x => x.toString.toLowerCase -> x).toMap

    def apply(value: String): ParameterLocation = fromString(value).getOrElse(UNDEFINED(value))

    def fromString(value: String): _root_.scala.Option[ParameterLocation] = byName.get(value.toLowerCase)

  }

}

package io.apibuilder.api.json.v0.models {

  package object json {
    import play.api.libs.json.__
    import play.api.libs.json.JsString
    import play.api.libs.json.Writes
    import play.api.libs.functional.syntax._
    import io.apibuilder.api.json.v0.models.json._

    private[v0] implicit val jsonReadsUUID: play.api.libs.json.Reads[_root_.java.util.UUID] = __.read[String].map { str =>
      _root_.java.util.UUID.fromString(str)
    }

    private[v0] implicit val jsonWritesUUID: play.api.libs.json.Writes[_root_.java.util.UUID] = (x: _root_.java.util.UUID) => play.api.libs.json.JsString(x.toString)

    private[v0] implicit val jsonReadsJodaDateTime: play.api.libs.json.Reads[_root_.org.joda.time.DateTime] = __.read[String].map { str =>
      _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(str)
    }

    private[v0] implicit val jsonWritesJodaDateTime: play.api.libs.json.Writes[_root_.org.joda.time.DateTime] = (x: _root_.org.joda.time.DateTime) => {
      play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x))
    }

    private[v0] implicit val jsonReadsJodaLocalDate: play.api.libs.json.Reads[_root_.org.joda.time.LocalDate] = __.read[String].map { str =>
      _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(str)
    }

    private[v0] implicit val jsonWritesJodaLocalDate: play.api.libs.json.Writes[_root_.org.joda.time.LocalDate] = (x: _root_.org.joda.time.LocalDate) => {
      play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x))
    }

    implicit val jsonReadsApibuilderApiJsonParameterLocation: play.api.libs.json.Reads[io.apibuilder.api.json.v0.models.ParameterLocation] = new play.api.libs.json.Reads[io.apibuilder.api.json.v0.models.ParameterLocation] {
      def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[io.apibuilder.api.json.v0.models.ParameterLocation] = {
        js match {
          case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(io.apibuilder.api.json.v0.models.ParameterLocation(v.value))
          case _ => {
            (js \ "value").validate[String] match {
              case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(io.apibuilder.api.json.v0.models.ParameterLocation(v))
              case err: play.api.libs.json.JsError =>
                (js \ "parameter_location").validate[String] match {
                  case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(io.apibuilder.api.json.v0.models.ParameterLocation(v))
                  case err: play.api.libs.json.JsError => err
                }
            }
          }
        }
      }
    }

    def jsonWritesApibuilderApiJsonParameterLocation(obj: io.apibuilder.api.json.v0.models.ParameterLocation) = {
      play.api.libs.json.JsString(obj.toString)
    }

    def jsObjectParameterLocation(obj: io.apibuilder.api.json.v0.models.ParameterLocation) = {
      play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString))
    }

    implicit def jsonWritesApibuilderApiJsonParameterLocation: play.api.libs.json.Writes[ParameterLocation] = {
      (obj: io.apibuilder.api.json.v0.models.ParameterLocation) => {
        jsonWritesApibuilderApiJsonParameterLocation(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonAnnotation: play.api.libs.json.Reads[Annotation] = {
      for {
        description <- (__ \ "description").readNullable[String]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Annotation(description, deprecation)
    }

    def jsObjectAnnotation(obj: io.apibuilder.api.json.v0.models.Annotation): play.api.libs.json.JsObject = {
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonAnnotation: play.api.libs.json.Writes[Annotation] = {
      (obj: io.apibuilder.api.json.v0.models.Annotation) => {
        jsObjectAnnotation(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonApiJson: play.api.libs.json.Reads[ApiJson] = {
      for {
        name <- (__ \ "name").read[String]
        info <- (__ \ "info").readNullable[io.apibuilder.api.json.v0.models.Info]
        namespace <- (__ \ "namespace").readNullable[String]
        baseUrl <- (__ \ "base_url").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        imports <- (__ \ "imports").readWithDefault[Seq[io.apibuilder.api.json.v0.models.Import]](Nil)
        headers <- (__ \ "headers").readWithDefault[Seq[io.apibuilder.api.json.v0.models.Header]](Nil)
        enums <- (__ \ "enums").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Enum]](Map.empty)
        interfaces <- (__ \ "interfaces").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Interface]](Map.empty)
        templates <- (__ \ "templates").readNullable[io.apibuilder.api.json.v0.models.Templates]
        unions <- (__ \ "unions").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Union]](Map.empty)
        models <- (__ \ "models").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Model]](Map.empty)
        resources <- (__ \ "resources").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Resource]](Map.empty)
        annotations <- (__ \ "annotations").readWithDefault[Map[String, io.apibuilder.api.json.v0.models.Annotation]](Map.empty)
        attributes <- (__ \ "attributes").readWithDefault[Seq[io.apibuilder.api.json.v0.models.Attribute]](Nil)
      } yield ApiJson(name, info, namespace, baseUrl, description, imports, headers, enums, interfaces, templates, unions, models, resources, annotations, attributes)
    }

    def jsObjectApiJson(obj: io.apibuilder.api.json.v0.models.ApiJson): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name),
        "imports" -> play.api.libs.json.Json.toJson(obj.imports),
        "headers" -> play.api.libs.json.Json.toJson(obj.headers),
        "enums" -> play.api.libs.json.Json.toJson(obj.enums),
        "interfaces" -> play.api.libs.json.Json.toJson(obj.interfaces),
        "unions" -> play.api.libs.json.Json.toJson(obj.unions),
        "models" -> play.api.libs.json.Json.toJson(obj.models),
        "resources" -> play.api.libs.json.Json.toJson(obj.resources),
        "annotations" -> play.api.libs.json.Json.toJson(obj.annotations),
        "attributes" -> play.api.libs.json.Json.toJson(obj.attributes)
      ) ++ (obj.info match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("info" -> jsObjectInfo(x))
      }) ++
      (obj.namespace match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("namespace" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.baseUrl match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("base_url" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.templates match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("templates" -> jsObjectTemplates(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonApiJson: play.api.libs.json.Writes[ApiJson] = {
      (obj: io.apibuilder.api.json.v0.models.ApiJson) => {
        jsObjectApiJson(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonAttribute: play.api.libs.json.Reads[Attribute] = {
      for {
        name <- (__ \ "name").read[String]
        value <- (__ \ "value").read[_root_.play.api.libs.json.JsObject]
      } yield Attribute(name, value)
    }

    def jsObjectAttribute(obj: io.apibuilder.api.json.v0.models.Attribute): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name),
        "value" -> obj.value
      )
    }

    implicit def jsonWritesApibuilderApiJsonAttribute: play.api.libs.json.Writes[Attribute] = {
      (obj: io.apibuilder.api.json.v0.models.Attribute) => {
        jsObjectAttribute(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonBody: play.api.libs.json.Reads[Body] = {
      for {
        `type` <- (__ \ "type").read[String]
        description <- (__ \ "description").readNullable[String]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Body(`type`, description, attributes, deprecation)
    }

    def jsObjectBody(obj: io.apibuilder.api.json.v0.models.Body): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "type" -> play.api.libs.json.JsString(obj.`type`)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonBody: play.api.libs.json.Writes[Body] = {
      (obj: io.apibuilder.api.json.v0.models.Body) => {
        jsObjectBody(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonContact: play.api.libs.json.Reads[Contact] = {
      for {
        name <- (__ \ "name").readNullable[String]
        url <- (__ \ "url").readNullable[String]
        email <- (__ \ "email").readNullable[String]
      } yield Contact(name, url, email)
    }

    def jsObjectContact(obj: io.apibuilder.api.json.v0.models.Contact): play.api.libs.json.JsObject = {
      (obj.name match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("name" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.url match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("url" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.email match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("email" -> play.api.libs.json.JsString(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonContact: play.api.libs.json.Writes[Contact] = {
      (obj: io.apibuilder.api.json.v0.models.Contact) => {
        jsObjectContact(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonDeprecation: play.api.libs.json.Reads[Deprecation] = {
      (__ \ "description").readNullable[String].map { x => new Deprecation(description = x) }
    }

    def jsObjectDeprecation(obj: io.apibuilder.api.json.v0.models.Deprecation): play.api.libs.json.JsObject = {
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonDeprecation: play.api.libs.json.Writes[Deprecation] = {
      (obj: io.apibuilder.api.json.v0.models.Deprecation) => {
        jsObjectDeprecation(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonEnum: play.api.libs.json.Reads[Enum] = {
      for {
        plural <- (__ \ "plural").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        values <- (__ \ "values").read[Seq[io.apibuilder.api.json.v0.models.EnumValue]]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Enum(plural, description, values, attributes, deprecation)
    }

    def jsObjectEnum(obj: io.apibuilder.api.json.v0.models.Enum): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "values" -> play.api.libs.json.Json.toJson(obj.values)
      ) ++ (obj.plural match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("plural" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonEnum: play.api.libs.json.Writes[Enum] = {
      (obj: io.apibuilder.api.json.v0.models.Enum) => {
        jsObjectEnum(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonEnumValue: play.api.libs.json.Reads[EnumValue] = {
      for {
        name <- (__ \ "name").read[String]
        value <- (__ \ "value").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield EnumValue(name, value, description, attributes, deprecation)
    }

    def jsObjectEnumValue(obj: io.apibuilder.api.json.v0.models.EnumValue): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name)
      ) ++ (obj.value match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonEnumValue: play.api.libs.json.Writes[EnumValue] = {
      (obj: io.apibuilder.api.json.v0.models.EnumValue) => {
        jsObjectEnumValue(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonField: play.api.libs.json.Reads[Field] = {
      for {
        name <- (__ \ "name").read[String]
        `type` <- (__ \ "type").read[String]
        description <- (__ \ "description").readNullable[String]
        required <- (__ \ "required").readWithDefault[Boolean](true)
        default <- (__ \ "default").readNullable[_root_.play.api.libs.json.JsValue]
        example <- (__ \ "example").readNullable[String]
        minimum <- (__ \ "minimum").readNullable[Long]
        maximum <- (__ \ "maximum").readNullable[Long]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        annotations <- (__ \ "annotations").readNullable[Seq[String]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Field(name, `type`, description, required, default, example, minimum, maximum, attributes, annotations, deprecation)
    }

    def jsObjectField(obj: io.apibuilder.api.json.v0.models.Field): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name),
        "type" -> play.api.libs.json.JsString(obj.`type`),
        "required" -> play.api.libs.json.JsBoolean(obj.required)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.default match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("default" -> x)
      }) ++
      (obj.example match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("example" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.minimum match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("minimum" -> play.api.libs.json.JsNumber(x))
      }) ++
      (obj.maximum match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("maximum" -> play.api.libs.json.JsNumber(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.annotations match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("annotations" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonField: play.api.libs.json.Writes[Field] = {
      (obj: io.apibuilder.api.json.v0.models.Field) => {
        jsObjectField(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonHeader: play.api.libs.json.Reads[Header] = {
      for {
        name <- (__ \ "name").read[String]
        `type` <- (__ \ "type").read[String]
        required <- (__ \ "required").readWithDefault[Boolean](true)
        description <- (__ \ "description").readNullable[String]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Header(name, `type`, required, description, attributes, deprecation)
    }

    def jsObjectHeader(obj: io.apibuilder.api.json.v0.models.Header): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name),
        "type" -> play.api.libs.json.JsString(obj.`type`),
        "required" -> play.api.libs.json.JsBoolean(obj.required)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonHeader: play.api.libs.json.Writes[Header] = {
      (obj: io.apibuilder.api.json.v0.models.Header) => {
        jsObjectHeader(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonImport: play.api.libs.json.Reads[Import] = {
      (__ \ "uri").read[String].map { x => new Import(uri = x) }
    }

    def jsObjectImport(obj: io.apibuilder.api.json.v0.models.Import): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "uri" -> play.api.libs.json.JsString(obj.uri)
      )
    }

    implicit def jsonWritesApibuilderApiJsonImport: play.api.libs.json.Writes[Import] = {
      (obj: io.apibuilder.api.json.v0.models.Import) => {
        jsObjectImport(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonInfo: play.api.libs.json.Reads[Info] = {
      for {
        contact <- (__ \ "contact").readNullable[io.apibuilder.api.json.v0.models.Contact]
        license <- (__ \ "license").readNullable[io.apibuilder.api.json.v0.models.License]
      } yield Info(contact, license)
    }

    def jsObjectInfo(obj: io.apibuilder.api.json.v0.models.Info): play.api.libs.json.JsObject = {
      (obj.contact match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("contact" -> jsObjectContact(x))
      }) ++
      (obj.license match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("license" -> jsObjectLicense(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonInfo: play.api.libs.json.Writes[Info] = {
      (obj: io.apibuilder.api.json.v0.models.Info) => {
        jsObjectInfo(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonInterface: play.api.libs.json.Reads[Interface] = {
      for {
        plural <- (__ \ "plural").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        fields <- (__ \ "fields").readNullable[Seq[io.apibuilder.api.json.v0.models.Field]]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Interface(plural, description, fields, attributes, deprecation)
    }

    def jsObjectInterface(obj: io.apibuilder.api.json.v0.models.Interface): play.api.libs.json.JsObject = {
      (obj.plural match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("plural" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.fields match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("fields" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonInterface: play.api.libs.json.Writes[Interface] = {
      (obj: io.apibuilder.api.json.v0.models.Interface) => {
        jsObjectInterface(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonLicense: play.api.libs.json.Reads[License] = {
      for {
        name <- (__ \ "name").read[String]
        url <- (__ \ "url").readNullable[String]
      } yield License(name, url)
    }

    def jsObjectLicense(obj: io.apibuilder.api.json.v0.models.License): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name)
      ) ++ (obj.url match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("url" -> play.api.libs.json.JsString(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonLicense: play.api.libs.json.Writes[License] = {
      (obj: io.apibuilder.api.json.v0.models.License) => {
        jsObjectLicense(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonModel: play.api.libs.json.Reads[Model] = {
      for {
        description <- (__ \ "description").readNullable[String]
        plural <- (__ \ "plural").readNullable[String]
        fields <- (__ \ "fields").readWithDefault[Seq[io.apibuilder.api.json.v0.models.Field]](Nil)
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        interfaces <- (__ \ "interfaces").readNullable[Seq[String]]
        templates <- (__ \ "templates").readNullable[Seq[io.apibuilder.api.json.v0.models.TemplateDeclaration]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Model(description, plural, fields, attributes, interfaces, templates, deprecation)
    }

    def jsObjectModel(obj: io.apibuilder.api.json.v0.models.Model): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "fields" -> play.api.libs.json.Json.toJson(obj.fields)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.plural match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("plural" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.interfaces match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("interfaces" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.templates match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("templates" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonModel: play.api.libs.json.Writes[Model] = {
      (obj: io.apibuilder.api.json.v0.models.Model) => {
        jsObjectModel(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonOperation: play.api.libs.json.Reads[Operation] = {
      for {
        method <- (__ \ "method").read[String]
        path <- (__ \ "path").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        body <- (__ \ "body").readNullable[io.apibuilder.api.json.v0.models.Body]
        parameters <- (__ \ "parameters").readNullable[Seq[io.apibuilder.api.json.v0.models.Parameter]]
        responses <- (__ \ "responses").readNullable[Map[String, io.apibuilder.api.json.v0.models.Response]]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Operation(method, path, description, body, parameters, responses, attributes, deprecation)
    }

    def jsObjectOperation(obj: io.apibuilder.api.json.v0.models.Operation): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "method" -> play.api.libs.json.JsString(obj.method)
      ) ++ (obj.path match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("path" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.body match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("body" -> jsObjectBody(x))
      }) ++
      (obj.parameters match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("parameters" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.responses match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("responses" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonOperation: play.api.libs.json.Writes[Operation] = {
      (obj: io.apibuilder.api.json.v0.models.Operation) => {
        jsObjectOperation(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonParameter: play.api.libs.json.Reads[Parameter] = {
      for {
        name <- (__ \ "name").read[String]
        `type` <- (__ \ "type").read[String]
        location <- (__ \ "location").readWithDefault[io.apibuilder.api.json.v0.models.ParameterLocation](io.apibuilder.api.json.v0.models.ParameterLocation.Query)
        description <- (__ \ "description").readNullable[String]
        required <- (__ \ "required").readWithDefault[Boolean](true)
        default <- (__ \ "default").readNullable[_root_.play.api.libs.json.JsValue]
        minimum <- (__ \ "minimum").readNullable[Long]
        maximum <- (__ \ "maximum").readNullable[Long]
        example <- (__ \ "example").readNullable[String]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Parameter(name, `type`, location, description, required, default, minimum, maximum, example, attributes, deprecation)
    }

    def jsObjectParameter(obj: io.apibuilder.api.json.v0.models.Parameter): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name),
        "type" -> play.api.libs.json.JsString(obj.`type`),
        "location" -> play.api.libs.json.JsString(obj.location.toString),
        "required" -> play.api.libs.json.JsBoolean(obj.required)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.default match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("default" -> x)
      }) ++
      (obj.minimum match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("minimum" -> play.api.libs.json.JsNumber(x))
      }) ++
      (obj.maximum match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("maximum" -> play.api.libs.json.JsNumber(x))
      }) ++
      (obj.example match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("example" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonParameter: play.api.libs.json.Writes[Parameter] = {
      (obj: io.apibuilder.api.json.v0.models.Parameter) => {
        jsObjectParameter(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonResource: play.api.libs.json.Reads[Resource] = {
      for {
        path <- (__ \ "path").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        operations <- (__ \ "operations").readWithDefault[Seq[io.apibuilder.api.json.v0.models.Operation]](Nil)
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        templates <- (__ \ "templates").readNullable[Seq[io.apibuilder.api.json.v0.models.TemplateDeclaration]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Resource(path, description, operations, attributes, templates, deprecation)
    }

    def jsObjectResource(obj: io.apibuilder.api.json.v0.models.Resource): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "operations" -> play.api.libs.json.Json.toJson(obj.operations)
      ) ++ (obj.path match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("path" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.templates match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("templates" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonResource: play.api.libs.json.Writes[Resource] = {
      (obj: io.apibuilder.api.json.v0.models.Resource) => {
        jsObjectResource(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonResponse: play.api.libs.json.Reads[Response] = {
      for {
        `type` <- (__ \ "type").read[String]
        headers <- (__ \ "headers").readNullable[Seq[io.apibuilder.api.json.v0.models.Header]]
        description <- (__ \ "description").readNullable[String]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
      } yield Response(`type`, headers, description, deprecation, attributes)
    }

    def jsObjectResponse(obj: io.apibuilder.api.json.v0.models.Response): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "type" -> play.api.libs.json.JsString(obj.`type`)
      ) ++ (obj.headers match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("headers" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonResponse: play.api.libs.json.Writes[Response] = {
      (obj: io.apibuilder.api.json.v0.models.Response) => {
        jsObjectResponse(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonTemplateDeclaration: play.api.libs.json.Reads[TemplateDeclaration] = {
      for {
        name <- (__ \ "name").read[String]
        cast <- (__ \ "cast").readNullable[Map[String, String]]
      } yield TemplateDeclaration(name, cast)
    }

    def jsObjectTemplateDeclaration(obj: io.apibuilder.api.json.v0.models.TemplateDeclaration): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "name" -> play.api.libs.json.JsString(obj.name)
      ) ++ (obj.cast match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("cast" -> play.api.libs.json.Json.toJson(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonTemplateDeclaration: play.api.libs.json.Writes[TemplateDeclaration] = {
      (obj: io.apibuilder.api.json.v0.models.TemplateDeclaration) => {
        jsObjectTemplateDeclaration(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonTemplates: play.api.libs.json.Reads[Templates] = {
      for {
        models <- (__ \ "models").readNullable[Map[String, io.apibuilder.api.json.v0.models.Model]]
        resources <- (__ \ "resources").readNullable[Map[String, io.apibuilder.api.json.v0.models.Resource]]
      } yield Templates(models, resources)
    }

    def jsObjectTemplates(obj: io.apibuilder.api.json.v0.models.Templates): play.api.libs.json.JsObject = {
      (obj.models match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("models" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.resources match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("resources" -> play.api.libs.json.Json.toJson(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonTemplates: play.api.libs.json.Writes[Templates] = {
      (obj: io.apibuilder.api.json.v0.models.Templates) => {
        jsObjectTemplates(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonUnion: play.api.libs.json.Reads[Union] = {
      for {
        plural <- (__ \ "plural").readNullable[String]
        discriminator <- (__ \ "discriminator").readNullable[String]
        description <- (__ \ "description").readNullable[String]
        types <- (__ \ "types").read[Seq[io.apibuilder.api.json.v0.models.UnionType]]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        interfaces <- (__ \ "interfaces").readNullable[Seq[String]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield Union(plural, discriminator, description, types, attributes, interfaces, deprecation)
    }

    def jsObjectUnion(obj: io.apibuilder.api.json.v0.models.Union): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "types" -> play.api.libs.json.Json.toJson(obj.types)
      ) ++ (obj.plural match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("plural" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.discriminator match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("discriminator" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.interfaces match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("interfaces" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonUnion: play.api.libs.json.Writes[Union] = {
      (obj: io.apibuilder.api.json.v0.models.Union) => {
        jsObjectUnion(obj)
      }
    }

    implicit def jsonReadsApibuilderApiJsonUnionType: play.api.libs.json.Reads[UnionType] = {
      for {
        `type` <- (__ \ "type").read[String]
        description <- (__ \ "description").readNullable[String]
        default <- (__ \ "default").readWithDefault[Boolean](false)
        discriminatorValue <- (__ \ "discriminator_value").readNullable[String]
        attributes <- (__ \ "attributes").readNullable[Seq[io.apibuilder.api.json.v0.models.Attribute]]
        deprecation <- (__ \ "deprecation").readNullable[io.apibuilder.api.json.v0.models.Deprecation]
      } yield UnionType(`type`, description, default, discriminatorValue, attributes, deprecation)
    }

    def jsObjectUnionType(obj: io.apibuilder.api.json.v0.models.UnionType): play.api.libs.json.JsObject = {
      play.api.libs.json.Json.obj(
        "type" -> play.api.libs.json.JsString(obj.`type`),
        "default" -> play.api.libs.json.JsBoolean(obj.default)
      ) ++ (obj.description match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("description" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.discriminatorValue match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("discriminator_value" -> play.api.libs.json.JsString(x))
      }) ++
      (obj.attributes match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("attributes" -> play.api.libs.json.Json.toJson(x))
      }) ++
      (obj.deprecation match {
        case None => play.api.libs.json.Json.obj()
        case Some(x) => play.api.libs.json.Json.obj("deprecation" -> jsObjectDeprecation(x))
      })
    }

    implicit def jsonWritesApibuilderApiJsonUnionType: play.api.libs.json.Writes[UnionType] = {
      (obj: io.apibuilder.api.json.v0.models.UnionType) => {
        jsObjectUnionType(obj)
      }
    }
  }
}

package io.apibuilder.api.json.v0 {

  object Bindables {

    import play.api.mvc.{PathBindable, QueryStringBindable}

    // import models directly for backwards compatibility with prior versions of the generator
    import Core._
    import Models._

    object Core {
      implicit def pathBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.DateTime] = ApibuilderPathBindable(ApibuilderTypes.dateTimeIso8601)
      implicit def queryStringBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.DateTime] = ApibuilderQueryStringBindable(ApibuilderTypes.dateTimeIso8601)

      implicit def pathBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.LocalDate] = ApibuilderPathBindable(ApibuilderTypes.dateIso8601)
      implicit def queryStringBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.LocalDate] = ApibuilderQueryStringBindable(ApibuilderTypes.dateIso8601)
    }

    object Models {
      import io.apibuilder.api.json.v0.models._

      val parameterLocationConverter: ApibuilderTypeConverter[io.apibuilder.api.json.v0.models.ParameterLocation] = new ApibuilderTypeConverter[io.apibuilder.api.json.v0.models.ParameterLocation] {
        override def convert(value: String): io.apibuilder.api.json.v0.models.ParameterLocation = io.apibuilder.api.json.v0.models.ParameterLocation(value)
        override def convert(value: io.apibuilder.api.json.v0.models.ParameterLocation): String = value.toString
        override def example: io.apibuilder.api.json.v0.models.ParameterLocation = io.apibuilder.api.json.v0.models.ParameterLocation.Path
        override def validValues: Seq[io.apibuilder.api.json.v0.models.ParameterLocation] = io.apibuilder.api.json.v0.models.ParameterLocation.all
      }
      implicit def pathBindableParameterLocation(implicit stringBinder: QueryStringBindable[String]): PathBindable[io.apibuilder.api.json.v0.models.ParameterLocation] = ApibuilderPathBindable(parameterLocationConverter)
      implicit def queryStringBindableParameterLocation(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[io.apibuilder.api.json.v0.models.ParameterLocation] = ApibuilderQueryStringBindable(parameterLocationConverter)
    }

    trait ApibuilderTypeConverter[T] {

      def convert(value: String): T

      def convert(value: T): String

      def example: T

      def validValues: Seq[T] = Nil

      def errorMessage(key: String, value: String, ex: java.lang.Exception): String = {
        val base = s"Invalid value '$value' for parameter '$key'. "
        validValues.toList match {
          case Nil => base + "Ex: " + convert(example)
          case values => base + ". Valid values are: " + values.mkString("'", "', '", "'")
        }
      }
    }

    object ApibuilderTypes {
      val dateTimeIso8601: ApibuilderTypeConverter[_root_.org.joda.time.DateTime] = new ApibuilderTypeConverter[_root_.org.joda.time.DateTime] {
        override def convert(value: String): _root_.org.joda.time.DateTime = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(value)
        override def convert(value: _root_.org.joda.time.DateTime): String = _root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(value)
        override def example: _root_.org.joda.time.DateTime = _root_.org.joda.time.DateTime.now
      }

      val dateIso8601: ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] = new ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] {
        override def convert(value: String): _root_.org.joda.time.LocalDate = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(value)
        override def convert(value: _root_.org.joda.time.LocalDate): String = _root_.org.joda.time.format.ISODateTimeFormat.date.print(value)
        override def example: _root_.org.joda.time.LocalDate = _root_.org.joda.time.LocalDate.now
      }
    }

    final case class ApibuilderQueryStringBindable[T](
      converters: ApibuilderTypeConverter[T]
    ) extends QueryStringBindable[T] {

      override def bind(key: String, params: Map[String, Seq[String]]): _root_.scala.Option[_root_.scala.Either[String, T]] = {
        params.getOrElse(key, Nil).headOption.map { v =>
          try {
            Right(
              converters.convert(v)
            )
          } catch {
            case ex: java.lang.Exception => Left(
              converters.errorMessage(key, v, ex)
            )
          }
        }
      }

      override def unbind(key: String, value: T): String = {
        s"$key=${converters.convert(value)}"
      }
    }

    final case class ApibuilderPathBindable[T](
      converters: ApibuilderTypeConverter[T]
    ) extends PathBindable[T] {

      override def bind(key: String, value: String): _root_.scala.Either[String, T] = {
        try {
          Right(
            converters.convert(value)
          )
        } catch {
          case ex: java.lang.Exception => Left(
            converters.errorMessage(key, value, ex)
          )
        }
      }

      override def unbind(key: String, value: T): String = {
        converters.convert(value)
      }
    }

  }

}