This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Pre-commit hook for running checkstyle on changed Java sources | |
# | |
# To use this you need: | |
# 1. checkstyle's jar file somewhere | |
# 2. a checkstyle XML check file somewhere | |
# 3. To configure git: | |
# * git config --add checkstyle.jar <location of jar> | |
# * git config --add checkstyle.checkfile <location of checkfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Immutable name */ | |
public class DefensiveName { | |
private String first; | |
private String last; | |
public DefensiveName(String first, String last) { | |
if (first == null) throw new IllegalArgumentException("first may not be null"); | |
if (last == null) throw new IllegalArgumentException("last may not be null"); | |
this.first = first; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThanksJavaBeans | |
def initialize(hash) | |
@hash = hash | |
end | |
def method_missing(symbol,*args) | |
if args.length == 0 | |
@hash[symbol] | |
else | |
super(symbol,args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int doit(float f) { | |
printf("%f\n",f); | |
} | |
int doitDouble(double d) { | |
printf("%f\n",d); | |
} | |
int main(int argc, char** argv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<properties> | |
<resteasy-version>1.1-RC2</resteasy-version> | |
</properties> | |
<groupId>com.example</groupId> | |
<artifactId>spring-resteasy</artifactId> | |
<packaging>war</packaging> | |
<version>1.0-SNAPSHOT</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> | |
<web-app> | |
<display-name>Archetype RestEasy Web Application</display-name> | |
<listener> | |
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> | |
</listener> | |
<listener> | |
<listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define a class called "Circle" | |
// it has a 1-arg constructor that takes an Int | |
class Circle(r:Int) { | |
// define a read-only field | |
val radius = r; | |
// define a method to compute diameter | |
def diameter = radius * 2 | |
// define a method to compute area | |
// we use braces since we need more than one line of code | |
def area = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait SuperComparable { | |
// extenders need only implement this method | |
// since it has no definition, it's abstract | |
// Also notice that the final colon and type indicate | |
// the return type of this method | |
def compareTo(x: Any): Int | |
// here we have a method that works in terms | |
// of the abstract one above, just as you | |
// would have in a Java abstract class | |
// Also note that we don't need to declare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface SuperComparable extends Comparable { | |
boolean lessThan(Object o); | |
boolean greaterThan(Object o); | |
boolean same(Object o); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cylinder(h: Int, r:Int) extends Circle(r) { | |
val height = h; | |
override def area = (super.area * 2) + (2 * 3.14 * r * height) | |
def volume = super.area * height | |
override def toString = "Cylinder with radius " + radius | |
} |
OlderNewer