Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:53:28+00:00 2026-05-27T02:53:28+00:00

I am trying to setup Dozer to perform a complex mapping between my two

  • 0

I am trying to setup Dozer to perform a complex mapping between my two entities. Essentially, I want it to convert my percentCompleted double to a boolean, based on if the value is 1 (100%) or not.

To do this I created the following method:

private void initEntityMappings()
{
    BeanMappingBuilder builder = new BeanMappingBuilder() {
        @Override
        protected void configure() {
            class isCompletedConverter implements CustomConverter {
                @Override
                public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
                    if (source == null) { return null; }

                    // Make sure the source is a double and the destination is a boolean
                    if (!(source instanceof Double) || !(destination instanceof Boolean))
                        throw new MappingException("Source was not a double or destination was not a boolean");

                    Boolean castedDest = (Boolean)destination;
                    Double castedSrc = (Double)source;
                    castedDest = castedSrc == 1;

                    return castedDest;
                }
            };

            mapping(TaskDetailsViewModel.class, TaskSummaryViewModel.class)
                .fields("percentCompleted", "isCompleted", customConverter(isCompletedConverter));
        }
    };  
}

The problem is that it the .fields() call complains because it says it can’t find the symbol for isCompletedConverter. As this is my first time doing a local class, I am sure I am doing something wrong but I can’t figure out exactly what.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:53:29+00:00Added an answer on May 27, 2026 at 2:53 am

    You are using the token isCompletedConverter (as oppose to an instance of isCompletedConverter, or it’s .class object) which isn’t valid at the particular point you use it. The way you’re including it is kind of like in a cast, or an instanceof check, but that’s a different syntax from a method invocation as customConverter appears to be.

    Either try isCompletedConverter.class, or new isCompletedConverter() depending on what customConverter() is doing (I can’t tell from the given code). It also might become clearer if you rename the local class from isCompletedConverter to IsCompletedConverter to match regular Java conventions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to setup a bidirectional localConnection (LC) between two flash objects on the
Trying to setup a simple Thread/Poll table mapping. Here is what I have: Threads
im trying to setup two listeners for one button. Here is my code: This
iam trying to setup an little search-engine for my website. I want to add
I'm trying to setup an automatic event countdown. What I want to do is
I'm trying setup a subset of boost and get it properly compiled using bjam,
Trying to setup an SSH server on Windows Server 2003. What are some good
Trying to setup a CodeIgniter based project for local development (LAMP stack), and once
After trying to setup my site for Google Webmaster Tools I found that my
I'm trying to setup CruiseControl.net at the moment. So far it works nice, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.