001/** 002 * Copyright (C) 2006-2020 Talend Inc. - www.talend.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.talend.sdk.component.api.service.schema; 017 018import java.util.ArrayList; 019import java.util.Collection; 020import java.util.List; 021 022import javax.json.bind.annotation.JsonbTransient; 023 024import org.talend.sdk.component.api.meta.Partial; 025 026import lombok.AllArgsConstructor; 027import lombok.Data; 028import lombok.NoArgsConstructor; 029 030@Partial("This API should support nested schema but the Studio is not yet ready.\n\n" 031 + "The cloud platform also doesn't use it yet.\n\nAlso prefer to use " 032 + "`org.talend.sdk.component.api.record.Schema` over this partial default implementation.") 033@Data 034@NoArgsConstructor 035@AllArgsConstructor 036@Deprecated // use SchemaBuilder instead of this implementation 037public class Schema implements org.talend.sdk.component.api.record.Schema { 038 039 private List<org.talend.sdk.component.api.record.Schema.Entry> entries; 040 041 // 1.0 compat 042 public Schema(final Collection<org.talend.sdk.component.api.record.Schema.Entry> entries) { 043 this.entries = new ArrayList<>(entries); 044 } 045 046 // 1.0 compat 047 public void setEntries(final Collection<org.talend.sdk.component.api.record.Schema.Entry> entries) { 048 this.entries = new ArrayList<>(entries); 049 } 050 051 @Override 052 public Type getType() { 053 return Type.RECORD; 054 } 055 056 @Override 057 public org.talend.sdk.component.api.record.Schema getElementSchema() { 058 return null; 059 } 060 061 @Data 062 @AllArgsConstructor 063 @NoArgsConstructor 064 @Deprecated 065 public static class Entry implements org.talend.sdk.component.api.record.Schema.Entry { 066 067 private String name; 068 069 private Schema.Type type; 070 071 // 1.0 compat 072 public Entry(final String name, final org.talend.sdk.component.api.service.schema.Type type) { 073 this.name = name; 074 this.type = org.talend.sdk.component.api.record.Schema.Type.valueOf(type.name()); 075 } 076 077 // 1.0 compat 078 public void setType(final org.talend.sdk.component.api.service.schema.Type type) { 079 this.type = org.talend.sdk.component.api.record.Schema.Type.valueOf(type.name()); 080 } 081 082 @Override 083 public String getRawName() { 084 return null; 085 } 086 087 @JsonbTransient 088 @Override 089 public String getOriginalFieldName() { 090 return null; 091 } 092 093 @Override 094 public boolean isNullable() { 095 return true; 096 } 097 098 @Override 099 public <T> T getDefaultValue() { 100 return null; 101 } 102 103 @Override 104 public org.talend.sdk.component.api.record.Schema getElementSchema() { 105 return null; 106 } 107 108 @Override 109 public String getComment() { 110 return null; 111 } 112 } 113}