Tabnine Logo
JdbiImmutables.registerImmutable
Code IndexAdd Tabnine to your IDE (free)

How to use
registerImmutable
method
in
org.jdbi.v3.core.mapper.immutables.JdbiImmutables

Best Java code snippets using org.jdbi.v3.core.mapper.immutables.JdbiImmutables.registerImmutable (Showing top 2 results out of 315)

origin: jdbi/jdbi

/**
 * Register bean arguments and row mapping for an {@code Immutable*} value class, expecting the default generated class and builder names.
 * @param spec the specification interface or abstract class
 * @param <S> the specification class
 * @return a plugin that configures type mapping for the given class
 */
public <S> JdbiImmutables registerImmutable(Class<S> spec) {
  final Class<? extends S> impl = classByPrefix("Immutable", spec);
  return registerImmutable(spec, impl, JdbiOptionals.findFirstPresent(
      () -> nullaryMethodOf(spec, "builder"),
      () -> nullaryMethodOf(impl, "builder"))
        .orElseThrow(() -> new IllegalArgumentException("Neither " + spec + " nor " + impl + " have a 'builder' method")));
}
origin: jdbi/jdbi

@Test
public void simpleTest() {
  jdbi.getConfig(JdbiImmutables.class).registerImmutable(Train.class);
  try (Handle handle = jdbi.open()) {
    handle.execute("create table train (name varchar, carriages int, observation_car boolean)");
    assertThat(
      handle.createUpdate("insert into train(name, carriages, observation_car) values (:name, :carriages, :observationCar)")
        .bindPojo(ImmutableTrain.builder().name("Zephyr").carriages(8).observationCar(true).build())
        .execute())
      .isEqualTo(1);
    assertThat(
      handle.createQuery("select * from train")
        .mapTo(Train.class)
        .findOnly())
      .extracting("name", "carriages", "observationCar")
      .containsExactly("Zephyr", 8, true);
  }
}
// end::example[]
org.jdbi.v3.core.mapper.immutablesJdbiImmutablesregisterImmutable

Javadoc

Register bean arguments and row mapping for an Immutable* value class, expecting the default generated class and builder names.

Popular methods of JdbiImmutables

  • <init>
  • classByPrefix
  • constructorOf
  • nullaryMethodOf
  • register
  • registerModifiable
    Register bean arguments and row mapping for an Modifiable* value class, using a supplied implementat

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now