Skip to content

Instantly share code, notes, and snippets.

List<ModelAnnotation<?>> annotations = new ArrayList<ModelAnnotation<?>>();
annotations.add( new ModelAnnotation<Measure>( "field1", new Measure() ) );
annotations.add( new ModelAnnotation<Attribute>( "field2", new Attribute() ) );
annotations.add( new ModelAnnotation<Dimension>( "field2", new Dimension() ) );
annotations.add( new ModelAnnotation<HierarchyLevel>( "field3", new HierarchyLevel() ) );
annotations.add( new ModelAnnotation<Measure>( "field4", new Measure() ) );
for ( ModelAnnotation<?> modelAnnotation : annotations ) {
// do something with modelAnnotation - what is it? a measure, dimension, etc....
}
if ( modelAnnotation.isMeasure() ) {
ModelAnnotation<Measure> measureAnnotation = (ModelAnnotation<Measure>) modelAnnotation;
}
@bytekast
bytekast / serverless.yml
Last active September 22, 2017 09:32
Serverless with Spring Boot / Spring Data
service: springboot-lambda
provider:
name: aws
runtime: java8
memorySize: 1536
timeout: 60
package:
artifact: build/distributions/springboot-lambda.zip
plugins {
id 'org.springframework.boot' version '1.5.2.RELEASE'
}
apply plugin: 'groovy'
repositories {
jcenter()
mavenCentral()
}
@SpringBootApplication
@Log4j
class LambdaHandler implements RequestHandler<Map, Response> {
@Memoized
ApplicationContext getApplicationContext(String[] args = []) {
return SpringApplication.run(LambdaHandler.class, args)
}
@Override
@Component
@CompileStatic
@Log4j
class DispatcherService {
@Autowired
List<Handler> handlers
Response dispatch(Request request) {
log.info("request: ${request}")
@Entity
@ToString
@CompileStatic
class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
String firstName
String lastName
import com.serverless.persistence.entities.User
import org.springframework.data.repository.CrudRepository
interface UserRepository extends CrudRepository<User, Long> {
List<User> findByLastName(String lastName)
}
interface Handler {
boolean route(Request request)
Response respond(Request request)
}
@Component
@Log4j
@CompileStatic
class CreateUser implements Handler {
@Autowired
private UserRepository userRepository
@Override
boolean route(Request request) {