Skip to content

Content Tagged "interface"

Page 1 of 1

Content Tagged "interface"

Initialize a Typescript Interface with JSON

February 20, 2017Category: Software
TL;DR: You can initialise a typescript interface using JSON objects. On my quest to load and save objects as JSON, I found that you can convert a JSON object to an interface via something called type assertion . Basically, if you have an interface: you can load a JSON object via JSON.parse(json…

Mock an Observable Interface

August 1, 2016Categories: Software, Tutorial
TL;DR: Use a doAnswer() with a new Answer<Observable<Type>>() if you have to mock observables. Today I wrote my first test where I had to mock an observable interface: where the User model is: Solution In my test class (named UserDatabaseTest ), I first mocked the interface: Then, my setup…

GoogleApiClient .connect() Interface or Class

February 14, 2016Category: Software
TL;DR : If it's your code, check the version play services ( com.google.android.gms:play-services-\* ). If you're using a library, check if the library has a version using play services >= 8.1.0 . If not, you'll need to clone and upgrade it yourself. The other day I got an interesting error coming…

TIL: Lambda Expressions

October 19, 2015Category: Software
TL;DR: A lambda expression is a shortcut notation to anonymous inner classes containing a single method . Usually, they define implementations for functional interfaces (interfaces declaring a single method). Today I finally found out what lambda expressions are (formally) by watching…

Use a Java Enum with Strings

March 10, 2015Category: Software
In my project I wanted to log messages using predefined categories. Traditionally, I do it via classes (if the messages are specific to the functions provided by that class): or an interface (pretty much the same thing): These solutions are prone to errors (e.g. when performing copy-paste and…

All tags