Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

opencredo/proxology

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

proxology

Note

This repo has been archived and is no longer under development. OpenCredo is now part of Trifork.

A Java 8 library for working with dynamic proxies. Includes a basic MagicMatcher implementation.

    public interface Person {
        static Person create(String name, int age) {
            Map<String, Object> properties = new HashMap<>();
            properties.put("name", name);
            properties.put("age", age);
            return Proxies.propertyMapping(Person.class, properties);
        }

        String getName();
        int getAge();
    }

    public interface PersonMatcher extends Matcher<Person> {
        static PersonMatcher aPerson() {
            return MagicMatcher.proxying(PersonMatcher.class);
        }

        PersonMatcher withName(String expected);
        PersonMatcher withName(Matcher<String> matcher);
        PersonMatcher withAge(int expected);
        PersonMatcher withAge(Matcher<Integer> ageMatcher);
    }

    @Test public void
    matchesLiterals() {
        assertThat(Person.create("Arthur Putey", 42), PersonMatcher.aPerson()
            .withName("Arthur Putey")
            .withAge(42));
    }

For more details see New Tricks With Dynamic Proxies In Java 8.

Releases

No releases published

Packages

 
 
 

Contributors

Languages