
com.facebook.swift.generator.swift2thrift.template.ThriftContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swift-generator Show documentation
Show all versions of swift-generator Show documentation
Code generator for Thrift IDLs
/*
* Copyright (C) 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.swift.generator.swift2thrift.template;
import com.google.common.collect.Lists;
import com.facebook.swift.codec.metadata.ThriftEnumMetadata;
import com.facebook.swift.codec.metadata.ThriftStructMetadata;
import com.facebook.swift.codec.metadata.ThriftType;
import com.facebook.swift.service.metadata.ThriftServiceMetadata;
import java.util.List;
import java.util.Map;
public class ThriftContext
{
private final String namespace;
private final List includes;
private final List thriftStructs = Lists.newArrayList();
private final List thriftEnums = Lists.newArrayList();
private final List thriftServices;
private final Map customNamespaces;
public ThriftContext(String namespace, List includes, List thriftTypes, List thriftServices, Map namespaceMap)
{
this.namespace = namespace;
this.includes = includes;
for (ThriftType t: thriftTypes) {
switch (t.getProtocolType()) {
case STRUCT:
this.thriftStructs.add(t.getStructMetadata());
break;
case ENUM:
this.thriftEnums.add(t.getEnumMetadata());
break;
default:
throw new IllegalStateException("Unknown protocol type: " + t.getProtocolType());
}
}
this.thriftServices = thriftServices;
customNamespaces = namespaceMap;
}
public List getStructs()
{
return thriftStructs;
}
public List getEnums()
{
return thriftEnums;
}
public String getNamespace()
{
return namespace;
}
public Map getCustomNamespaces()
{
return customNamespaces;
}
public List getServices()
{
return thriftServices;
}
public List getIncludes()
{
return includes;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy