Skip to content

Commit

Permalink
https://github.com/xcesco/kripton/issues/18
Browse files Browse the repository at this point in the history
  • Loading branch information
xcesco committed May 20, 2019
1 parent a3c2dff commit d2071ca
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 4 deletions.
@@ -0,0 +1,27 @@
package com.abubusoft.kripton.android;

import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView.Adapter;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;

public class KriptonRecyclerViewAdapter<VH extends ViewHolder> extends Adapter<VH> {

@Override
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
// TODO Auto-generated method stub
return null;
}

@Override
public void onBindViewHolder(VH holder, int position) {
// TODO Auto-generated method stub

}

@Override
public int getItemCount() {
// TODO Auto-generated method stub
return 0;
}

}
2 changes: 1 addition & 1 deletion kripton-processor/schemas/artist_schema_1.sql
Expand Up @@ -2,7 +2,7 @@
--
-- Filename: artist_schema_1.sql
--
-- Date: Thu May 02 00:00:00 CEST 2019
-- Date: Mon May 20 17:07:08 CEST 2019
--
------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion kripton-processor/schemas/school_schema_2.sql
Expand Up @@ -2,7 +2,7 @@
--
-- Filename: school_schema_2.sql
--
-- Date: Wed May 01 23:58:54 CEST 2019
-- Date: Mon May 20 17:06:36 CEST 2019
--
------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion kripton-processor/schemas/students_schema_1.sql
Expand Up @@ -2,7 +2,7 @@
--
-- Filename: students_schema_1.sql
--
-- Date: Thu May 02 00:05:49 CEST 2019
-- Date: Mon May 20 17:10:12 CEST 2019
--
------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion kripton-processor/schemas/xeno_schema_1.sql
Expand Up @@ -2,7 +2,7 @@
--
-- Filename: xeno_schema_1.sql
--
-- Date: Thu May 02 00:00:04 CEST 2019
-- Date: Mon May 20 17:07:10 CEST 2019
--
------------------------------------------------------------------------------------

Expand Down
Expand Up @@ -35,6 +35,7 @@
import com.abubusoft.kripton.processor.bind.model.BindProperty;
import com.abubusoft.kripton.processor.core.AssertKripton;
import com.abubusoft.kripton.processor.core.reflect.TypeUtility;
import com.abubusoft.kripton.processor.exceptions.UnsupportedFieldTypeException;
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
Expand All @@ -56,13 +57,17 @@ public abstract class BindTransformer {
* @return transform
*/
public static BindTransform lookup(BindProperty property) {
try {
TypeName typeName = property.getPropertyType().getTypeName();

if (property.hasTypeAdapter()) {
typeName = typeName(property.typeAdapter.dataType);
}

return lookup(typeName);
} catch(UnsupportedFieldTypeException e) {
throw(UnsupportedFieldTypeException.merge(e, property));
}
}

/**
Expand Down
Expand Up @@ -15,6 +15,7 @@
*******************************************************************************/
package com.abubusoft.kripton.processor.exceptions;

import com.abubusoft.kripton.processor.bind.model.BindProperty;
import com.abubusoft.kripton.processor.sqlite.model.SQLiteModelMethod;
import com.squareup.javapoet.TypeName;

Expand Down Expand Up @@ -47,4 +48,16 @@ public UnsupportedFieldTypeException(SQLiteModelMethod method, TypeName typeName
public UnsupportedFieldTypeException(TypeName typeName) {
super(String.format("Unsupported type '%s' is used", typeName));
}

public UnsupportedFieldTypeException(String description) {
super(description);
}

/*public UnsupportedFieldTypeException(PropertyTypeName typeName) {
super(String.format("Unsupported type '%s' is used", typeName));
}*/

public static UnsupportedFieldTypeException merge(UnsupportedFieldTypeException e, BindProperty property) {
return new UnsupportedFieldTypeException(String.format("In POJO '%s' field '%s' is defined as unsupported type '%s'", property.getParent().getElement().asType(), property.getName(), property.getPropertyType().getTypeName()));
}
}
Expand Up @@ -26,6 +26,7 @@
import bind.feature.kotlin.TestBindTypeKotlinCompileSuite;
import bind.feature.namespace.CompileNamespaceTestSuite;
import bind.feature.typeadapter.kripton87.Test87CompileSuite;
import bind.git18.TestCompileGit18;
import bind.kripton110.TestCompile110;
import bind.kripton42faster.Test42CompileSuite;
import bind.kripton70.Test70CompileSuite;
Expand Down Expand Up @@ -74,6 +75,8 @@
TestCompile110.class,
TestFilmCompile.class,

TestCompileGit18.class,

// features
CompileNamespaceTestSuite.class,
})
Expand Down
33 changes: 33 additions & 0 deletions kripton-processor/src/test/java/bind/git18/Bean.java
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright 2015, 2016 Francesco Benincasa (info@abubusoft.com).
*
* 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 bind.git18;

import com.abubusoft.kripton.annotation.BindType;

// TODO: Auto-generated Javadoc
/**
* The Class Bean70A.
*/
@BindType("root")
public class Bean {

/** The value bean. */
public Object valueBean;

/** The value string. */
public String valueString;

}
49 changes: 49 additions & 0 deletions kripton-processor/src/test/java/bind/git18/TestCompileGit18.java
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright 2015, 2017 Francesco Benincasa (info@abubusoft.com).
*
* 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 bind.git18;

import java.io.IOException;

import org.junit.Test;

import com.abubusoft.kripton.processor.exceptions.UnsupportedFieldTypeException;

import bind.AbstractBindTypeProcessorTest;


/**
* Test bean field.
*
* @author Francesco Benincasa (info@abubusoft.com)
*/
public class TestCompileGit18 extends AbstractBindTypeProcessorTest {

/**
* Test compile.
*
* @throws IOException Signals that an I/O exception has occurred.
* @throws InstantiationException the instantiation exception
* @throws IllegalAccessException the illegal access exception
*/
@Test
public void testCompile() throws IOException, InstantiationException, IllegalAccessException {
this.expectedException(UnsupportedFieldTypeException.class, "UnsupportedFieldTypeException: In POJO 'bind.git18.Bean' field 'valueBean' is defined as unsupported type 'java.lang.Object'");
buildBindProcessorTest(Bean.class);
}



}

0 comments on commit d2071ca

Please sign in to comment.