• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Cupboard类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中nl.qbusict.cupboard.Cupboard的典型用法代码示例。如果您正苦于以下问题:Java Cupboard类的具体用法?Java Cupboard怎么用?Java Cupboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Cupboard类属于nl.qbusict.cupboard包,在下文中一共展示了Cupboard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Override
public <T> EntityConverter<T> create(Cupboard cupboard, Class<T> type) {
    if (type == Book.class) {
        EntityConverter<Book> delegate = new ReflectiveEntityConverter<Book>(cupboard, Book.class) {
            @Override
            protected boolean isIgnored(Field field) {
                return super.isIgnored(field) || ExtraInfo.class == field.getType();
            }

            @Override
            public Book fromCursor(Cursor cursor) {
                Book book = super.fromCursor(cursor);
                book.title = "TITLE: "+book.title;
                return book;
            }
        };
        return (EntityConverter<T>) delegate;
    }
    return null;
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:21,代码来源:SampleSQLiteOpenHelper.java


示例2: provideCupboard

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Provides @Singleton
Cupboard provideCupboard() {
    Cupboard cupboard = new CupboardBuilder()
            .registerFieldConverter(Intent.class, new IntentFieldConverter())
            .registerFieldConverter(Uri.class, new UriFieldConverter())
            .build();

    cupboard.register(Artwork.class);
    return cupboard;
}
 
开发者ID:tasomaniac,项目名称:MuzeiHistory,代码行数:11,代码来源:DataModule.java


示例3: ReflectiveEntityConverter

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
/**
 * Constructor suitable for {@link nl.qbusict.cupboard.convert.EntityConverterFactory}s that only need minor
 * changes to the default behavior of this converter, not requiring a sub class.
 *
 * @param cupboard          the cupboard instance
 * @param entityClass       the entity class
 * @param ignoredFieldNames a collection of field names that should be ignored as an alternative to implementing {@link #isIgnored(java.lang.reflect.Field)}
 * @param additionalColumns a collection of additional columns that will be requested from the cursor
 */
public ReflectiveEntityConverter(Cupboard cupboard, Class<T> entityClass, Collection<String> ignoredFieldNames, Collection<Column> additionalColumns) {
    mCupboard = cupboard;
    mUseAnnotations = cupboard.isUseAnnotations();
    Field[] fields = getAllFields(entityClass);
    ArrayList<Column> columns = new ArrayList<Column>(fields.length);
    this.mClass = entityClass;
    List<Property> properties = new ArrayList<Property>();
    for (Field field : fields) {
        if (ignoredFieldNames.contains(field.getName()) || isIgnored(field)) {
            continue;
        }
        Type type = field.getGenericType();
        FieldConverter<?> converter = getFieldConverter(field);
        if (converter == null) {
            throw new IllegalArgumentException("Do not know how to convert field " + field.getName() + " in entity " + entityClass.getName() + " of type " + type);
        }
        if (converter.getColumnType() == null) {
            continue;
        }
        Property prop = new Property();
        prop.field = field;
        if (!field.isAccessible()) {
            field.setAccessible(true);
        }
        prop.name = getColumn(field);
        prop.type = field.getType();
        prop.fieldConverter = (FieldConverter<Object>) converter;
        prop.columnType = converter.getColumnType();
        properties.add(prop);
        if (BaseColumns._ID.equals(prop.name)) {
            mIdProperty = prop;
        }
        columns.add(new Column(prop.name, prop.columnType, getIndexes(field)));
    }
    columns.addAll(additionalColumns);
    this.mColumns = Collections.unmodifiableList(columns);
    this.mProperties = properties.toArray(new Property[properties.size()]);
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:48,代码来源:ReflectiveEntityConverter.java


示例4: create

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Override
public FieldConverter<?> create(Cupboard cupboard, Type type) {
    // we don't handle any generic types here
    if (!(type instanceof Class)) {
        return null;
    }
    return sTypeConverters.get(type);
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:9,代码来源:DefaultFieldConverterFactory.java


示例5: addDefaultEntityConverterFactories

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
private void addDefaultEntityConverterFactories() {
    mEntityConverterFactories.add(new EntityConverterFactory() {
        @Override
        public <T> EntityConverter<T> create(Cupboard cupboard, Class<T> type) {
            return new ReflectiveEntityConverter<T>(cupboard, type);
        }
    });
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:9,代码来源:ConverterRegistry.java


示例6: testAnnotatedEntity

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public void testAnnotatedEntity() {
    Cupboard cupboard = new Cupboard();
    cupboard.register(TestAnnotatedEntity.class);

    Cupboard annotatedCupboard = new CupboardBuilder().useAnnotations().build();
    annotatedCupboard.register(TestAnnotatedEntity.class);

    ReflectiveEntityConverter<TestAnnotatedEntity> converter = new ReflectiveEntityConverter<TestAnnotatedEntity>(cupboard, TestAnnotatedEntity.class);
    ReflectiveEntityConverter<TestAnnotatedEntity> annotatedConverter = new ReflectiveEntityConverter<TestAnnotatedEntity>(annotatedCupboard, TestAnnotatedEntity.class);

    MatrixCursor cursor = new MatrixCursor(new String[]{"_id", "myStringValue", "data1"});
    cursor.addRow(new Object[]{1L, "test", "test2"});
    cursor.moveToPosition(0);
    TestAnnotatedEntity entity = converter.fromCursor(TestHelper.newPreferredColumnOrderCursorWrapper(cursor, converter.getColumns()));
    assertEquals(1L, entity._id.longValue());
    assertEquals("test", entity.myStringValue);
    assertNull(entity.renamedStringValue);
    entity = annotatedConverter.fromCursor(TestHelper.newPreferredColumnOrderCursorWrapper(cursor, annotatedConverter.getColumns()));
    assertEquals(1L, entity._id.longValue());
    assertEquals("test", entity.myStringValue);
    assertEquals("test2", entity.renamedStringValue);

    ContentValues values = new ContentValues();
    annotatedConverter.toValues(entity, values);
    assertTrue(values.containsKey("data1"));
    assertEquals("test2", values.getAsString("data1"));
    assertTrue(values.containsKey("_id"));
    assertTrue(values.containsKey("myStringValue"));
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:30,代码来源:ReflectiveConverterTest.java


示例7: testIgnoreAnnotation

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public void testIgnoreAnnotation() {
    Cupboard cupboard = new Cupboard();
    cupboard.register(TestAnnotatedEntity.class);

    Cupboard annotatedCupboard = new CupboardBuilder().useAnnotations().build();
    annotatedCupboard.register(TestAnnotatedEntity.class);

    ReflectiveEntityConverter<TestAnnotatedEntity> converter = new ReflectiveEntityConverter<TestAnnotatedEntity>(cupboard, TestAnnotatedEntity.class);
    ReflectiveEntityConverter<TestAnnotatedEntity> annotatedConverter = new ReflectiveEntityConverter<TestAnnotatedEntity>(annotatedCupboard, TestAnnotatedEntity.class);

    assertEquals(4, converter.getColumns().size());
    assertEquals(3, annotatedConverter.getColumns().size());
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:14,代码来源:ReflectiveConverterTest.java


示例8: testCaseInsensitiveColumnMapping

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public void testCaseInsensitiveColumnMapping() {
    Cupboard cupboard = new Cupboard();
    cupboard.register(TestEntity.class);
    ReflectiveEntityConverter<TestEntity> translator = new ReflectiveEntityConverter<TestEntity>(cupboard, TestEntity.class);
    TestEntity te = new TestEntity();
    te.booleanObjectProperty = true;
    te.booleanProperty = false;
    te.doubleObjectProperty = 100d;
    te.doubleProperty = 200.2d;
    te.floatObjectProperty = 101f;
    te.floatProperty = 202f;
    te.intObjectProperty = 10;
    te.intObjectProperty = 11;
    te.longObjectProperty = 12L;
    te.longProperty = 13L;
    te.shortObjectProperty = 1;
    te.shortProperty = 2;
    te.stringProperty = "test";

    ContentValues values = new ContentValues(50);
    translator.toValues(te, values);
    Set<Entry<String, Object>> vs = values.valueSet();
    String[] cols = new String[vs.size() - 1];
    int index = 0;
    List<Object> vals = new ArrayList<Object>(vs.size());
    for (Entry<String, Object> entry : vs) {
        if (!"bytearrayproperty".equalsIgnoreCase(entry.getKey())) {
            cols[index++] = entry.getKey().toUpperCase();
            vals.add(entry.getValue());
        }
    }
    MatrixCursor cursor = new MatrixCursor(cols);
    cursor.addRow(vals);
    cursor.moveToFirst();
    TestEntity converted = translator.fromCursor(newPreferredColumnOrderCursorWrapper(cursor, translator.getColumns()));
    assertEquals(te, converted);
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:38,代码来源:ReflectiveConverterTest.java


示例9: create

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Override
public FieldConverter<?> create(Cupboard cupboard, Type type) {
  if (type.equals(this.type)) {
    return new GsonFieldConverter(gson, type);
  }
  return null;
}
 
开发者ID:chiuki,项目名称:friendspell,代码行数:8,代码来源:GsonFieldConverterFactory.java


示例10: setUp

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	Cupboard cupboard = new CupboardBuilder().build();
	cupboard.register(TestEntity.class);
	InstrumentationRegistry.getTargetContext().deleteDatabase(TEST_DATABASE);
	db = new TestDbHelper(InstrumentationRegistry.getTargetContext(), cupboard, TEST_DATABASE).getWritableDatabase();
	rxDatabase = RxCupboard.with(cupboard, db);
}
 
开发者ID:erickok,项目名称:RxCupboard,代码行数:9,代码来源:CrudTest.java


示例11: setUp

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	Cupboard cupboard = new CupboardBuilder().build();
	cupboard.register(TestEntity.class);
	cupboard.register(TestEntity2.class);
	InstrumentationRegistry.getTargetContext().deleteDatabase(TEST_DATABASE);
	db = new TestDbHelper(InstrumentationRegistry.getTargetContext(), cupboard, TEST_DATABASE).getWritableDatabase();
	rxDatabase = RxCupboard.with(cupboard, db);
}
 
开发者ID:erickok,项目名称:RxCupboard,代码行数:10,代码来源:ChangesTest.java


示例12: getInstance

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public static Cupboard getInstance() {
    if (cupboard == null) {
        cupboard = new CupboardBuilder().build();
    }
    return cupboard;
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:7,代码来源:LocalCupboard.java


示例13: getAnnotatedInstance

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public static Cupboard getAnnotatedInstance() {
    return new CupboardBuilder(getInstance())
            .useAnnotations()
            .build();
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:6,代码来源:LocalCupboard.java


示例14: cupboard

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public synchronized static Cupboard cupboard() {
	return cupboardAll;
}
 
开发者ID:erickok,项目名称:ratebeer,代码行数:4,代码来源:CupboardDbHelper.java


示例15: ConverterRegistry

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public ConverterRegistry(Cupboard cupboard) {
    this.mCupboard = cupboard;
    addDefaultEntityConverterFactories();
    addDefaultFieldConverterFactories();
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:6,代码来源:ConverterRegistry.java


示例16: testPrivateFields

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public void testPrivateFields() {
    Cupboard cupboard = new Cupboard();
    cupboard.register(PrivateEntity.class);
    ReflectiveEntityConverter<PrivateEntity> converter = new ReflectiveEntityConverter<PrivateEntity>(cupboard, PrivateEntity.class);
    assertEquals(3, converter.getColumns().size());
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:7,代码来源:ReflectiveConverterTest.java


示例17: testInheritedPrivateFields

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public void testInheritedPrivateFields() {
    Cupboard cupboard = new Cupboard();
    cupboard.register(PrivateInheritedEntity.class);
    ReflectiveEntityConverter<PrivateInheritedEntity> converter = new ReflectiveEntityConverter<PrivateInheritedEntity>(cupboard, PrivateInheritedEntity.class);
    assertEquals(4, converter.getColumns().size());
}
 
开发者ID:electrolobzik,项目名称:cupboard,代码行数:7,代码来源:ReflectiveConverterTest.java


示例18: RxDatabase

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
RxDatabase(Cupboard cupboard, DatabaseCompartment dc, SQLiteDatabase db) {
	this.cupboard = cupboard;
	this.dc = dc;
	this.db = db;
}
 
开发者ID:erickok,项目名称:RxCupboard,代码行数:6,代码来源:RxDatabase.java


示例19: with

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
public static RxDatabase with(Cupboard cupboard, SQLiteDatabase db) {
	return new RxDatabase(cupboard, cupboard.withDatabase(db), db);
}
 
开发者ID:erickok,项目名称:RxCupboard,代码行数:4,代码来源:RxCupboard.java


示例20: RxCursor

import nl.qbusict.cupboard.Cupboard; //导入依赖的package包/类
RxCursor(Cupboard cupboard, Cursor cursor) {
	this.cursor = cupboard.withCursor(cursor);
}
 
开发者ID:erickok,项目名称:RxCupboard,代码行数:4,代码来源:RxCursor.java



注:本文中的nl.qbusict.cupboard.Cupboard类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IRecipe类代码示例发布时间:2022-05-23
下一篇:
Java HolidayManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap