| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (edn.clj)

This example Java source code file (edn.clj) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

author, copyright, eclipse, halloway, hickey, license, print, public, returns, stuart, the, throwable, value, you

The edn.clj Java example source code

;   Copyright (c) Rich Hickey. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (
;   which can be found in the file epl-v10.html at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.

; Author: Stuart Halloway

(ns clojure.test-clojure.edn
  (:require [clojure.test.generative :refer (defspec)]
            [clojure.test-clojure.generators :as cgen]
            [clojure.edn :as edn]))

(defn roundtrip
  "Print an object and read it back as edn. Returns rather than throws
   any exceptions."
  (binding [*print-length* nil
            *print-dup* nil
            *print-level* nil]
     (-> o pr-str edn/read-string)
     (catch Throwable t t))))

(defspec types-that-should-roundtrip
  [^{:tag cgen/ednable} o]
  (when-not (= o %)
    (throw (ex-info "Value cannot roundtrip, see ex-data" {:printed o :read %}))))

(defspec types-that-should-not-roundtrip
  [^{:tag cgen/non-ednable} o]
  (when-not (instance? Throwable %)
    (throw (ex-info "edn/read should have thrown, see ex-data" {:printed o :read %}))))

Other Java examples (source code examples)

Here is a short list of links related to this Java edn.clj source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.