Search in sources :

Example 1 with Student

use of sqlite.feature.schema.version2.Student in project java-certification by springapidev.

the class NowJava8FilterMap method main.

public static void main(String[] args) {
    List<Student> students = Arrays.asList(new Student("Munna", 30), new Student("Emon", 20), new Student("Rashidul", 30));
    String name = students.stream().filter(x -> "Munna".equals(x.getName())).map(// convert stream to String
    Student::getName).findAny().orElse("");
    System.out.println("name : " + name);
    int age = students.stream().filter(x -> "Munna".equals(x.getName())).map(// convert stream to String
    Student::getAge).findAny().orElse(0);
    System.out.println("age : " + age);
    List<String> collect = students.stream().map(Student::getName).collect(Collectors.toList());
    collect.forEach(System.out::println);
    List<Integer> collects = students.stream().map(Student::getAge).collect(Collectors.toList());
    collects.forEach(System.out::println);
    out.println("hi..........");
}
Also used : Arrays(java.util.Arrays) List(java.util.List) Student(com.coderbd.day19.ch8.streamsFilter.ex2.Student) Collectors(java.util.stream.Collectors) System.out(java.lang.System.out) Student(com.coderbd.day19.ch8.streamsFilter.ex2.Student) System.out(java.lang.System.out)

Example 2 with Student

use of sqlite.feature.schema.version2.Student in project kripton by xcesco.

the class TestSchemaRuntime method testRun.

@Test
public void testRun() {
    BindSchoolDataSource.build(DataSourceOptions.builder().databaseLifecycleHandler(new DatabaseLifecycleHandler() {

        @Override
        public void onUpdate(SQLiteDatabase db, int oldVersion, int newVersion, boolean upgrade) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onCreate(SQLiteDatabase database) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onConfigure(SQLiteDatabase database) {
        // TODO Auto-generated method stub
        }
    }).build());
    try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
        DaoProfessorImpl dao = dataSource.getDaoProfessor()) {
        // dataSource.execute(transaction);
        for (int i = 0; i < 10; i++) {
            Professor professor = new Professor();
            professor.name = String.format("professor%03d", i);
            professor.surname = "surname" + i;
            professor.birthDate = new Date();
            dao.insert(professor);
        }
    }
    try (BindSchoolDataSource dataSource = BindSchoolDataSource.open();
        DaoStudentImpl dao = dataSource.getDaoStudent()) {
        // dataSource.execute(transaction);
        for (int i = 0; i < 100; i++) {
            Student student = new Student();
            student.name = String.format("professor%03d", i);
            student.location = String.format("location%03d", i);
            dao.insert(student);
        }
    }
}
Also used : DaoProfessorImpl(sqlite.feature.schema.version2.DaoProfessorImpl) Professor(sqlite.feature.schema.version2.Professor) DatabaseLifecycleHandler(com.abubusoft.kripton.android.sqlite.DatabaseLifecycleHandler) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) BindSchoolDataSource(sqlite.feature.schema.version2.BindSchoolDataSource) DaoStudentImpl(sqlite.feature.schema.version2.DaoStudentImpl) Student(sqlite.feature.schema.version2.Student) Date(java.util.Date) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 BaseAndroidTest (base.BaseAndroidTest)1 DatabaseLifecycleHandler (com.abubusoft.kripton.android.sqlite.DatabaseLifecycleHandler)1 Student (com.coderbd.day19.ch8.streamsFilter.ex2.Student)1 System.out (java.lang.System.out)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 BindSchoolDataSource (sqlite.feature.schema.version2.BindSchoolDataSource)1 DaoProfessorImpl (sqlite.feature.schema.version2.DaoProfessorImpl)1 DaoStudentImpl (sqlite.feature.schema.version2.DaoStudentImpl)1 Professor (sqlite.feature.schema.version2.Professor)1 Student (sqlite.feature.schema.version2.Student)1